Giter Site home page Giter Site logo

Comments (3)

eliocamp avatar eliocamp commented on August 22, 2024 1

I think a better approach is to not try to do anything fancy and since I'm letting ncdf4 do all the reading, just let it tell me if it works or not. I'll just remove the checks and add some error trapping so it's clear that the error came from ReadNetCDF().

from metr.

eliocamp avatar eliocamp commented on August 22, 2024

It seems that RCurl is not recognising it as a valid URL. If I navigate to that URL I get

Error {
    code = 400;
    message = "Unrecognized request";
};

So something might be going on. It seems that RCurl is not as robust as one hopes to detect if something is a URL.

from metr.

pascaloettli avatar pascaloettli commented on August 22, 2024

Adding .dds at the end of the filename (i.e., https://psl.noaa.gov/thredds/dodsC/Datasets/ncep.reanalysis2/Monthlies/LTMs/gaussian_grid/air.2m.mon.ltm.nc.dds) gives:

Dataset {
    Float32 level[level = 1];
    Float32 lat[lat = 94];
    Float32 lon[lon = 192];
    Float64 time[time = 12];
    Float64 climatology_bounds[time = 12][nbnds = 2];
    Grid {
     ARRAY:
        Float32 air[time = 12][level = 1][lat = 94][lon = 192];
     MAPS:
        Float64 time[time = 12];
        Float32 level[level = 1];
        Float32 lat[lat = 94];
        Float32 lon[lon = 192];
    } air;
    Grid {
     ARRAY:
        Int16 valid_yr_count[time = 12][level = 1][lat = 94][lon = 192];
     MAPS:
        Float64 time[time = 12];
        Float32 level[level = 1];
        Float32 lat[lat = 94];
        Float32 lon[lon = 192];
    } valid_yr_count;
} Datasets/ncep.reanalysis2/Monthlies/LTMs/gaussian_grid/air.2m.mon.ltm.nc;

And

f <- "https://psl.noaa.gov/thredds/dodsC/Datasets/ncep.reanalysis2/Monthlies/LTMs/gaussian_grid/air.2m.mon.ltm.nc.dds"
unname(file.access(f, 4) == 0 | RCurl::url.exists(f))
[1] TRUE

So maybe a two-step test is possible. First with the .nc extension only. If FALSE, adding .dds extension and test again. If TRUE, ncdf4::nc_open() can read the .nc file, as showed in the first post.

from metr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.