Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting mostly NaN from NodeFileCompose, and I don't know why #83

Open
pmansito opened this issue Aug 16, 2024 · 0 comments
Open

Getting mostly NaN from NodeFileCompose, and I don't know why #83

pmansito opened this issue Aug 16, 2024 · 0 comments

Comments

@pmansito
Copy link

Hello all,
I am trying to generate the CPS values, using @stella-bourdin's CPyS python package. She requires the use NodeFileCompose to generate the snapshots file. My snapshots file is filled with NaNs, even with the example she provides in CPyS Github page. She has been so kind as to test herself those files, and she gets the correct values, not a single NaN. But not me!

I have tested it on my Apple M1, on an Intel MacBook Air, an on an AMD ChromeFlex PC (Debian Linux). Both compiling from source code and downloading from anaconda. With all the combinations of source and computer, I get NaNs. I am sure I am making one, probably more, mistakes, but for the life of me that I can't see them.

The command I run is:

$NODEFILECOMPOSE \
    --in_nodefile "Dale.csv" \
    --in_nodefile_type SN \
    --in_fmt "(auto)" \
    --in_data "download_dale.nc" \
    --var "z(:)" \
    --out_grid "RAD" \
    --out_data "snaps_Dale.nc" \
    --dx 0.5 \
    --resx 10  \
    --varout "zg" \
    --snapshots \
    --latname latitude \
    --lonname longitude \
    --regional

The csv input file is Dale.csv, downloaded from CPyS. These are its first rows:

,Unnamed: 0,track_id,time,lon,lat,hemisphere,basin,sshs,slp,wind10,year,month,day,hour,ET,B,VTU,VTL,season
2011,2011,1277,1996-11-05 00:00:00,150.5,9.0,N,WNP,0,998.7262,14.61792,1996,11,5,0,,43.66187499999796,385.875,387.5,1996
2012,2012,1277,1996-11-05 06:00:00,152.0,10.25,N,WNP,0,995.9969,17.62081,1996,11,5,6,,68.44012500000099,545.25,563.125,1996
2013,2013,1277,1996-11-05 12:00:00,152.25,11.25,N,WNP,0,996.2644,19.88938,1996,11,5,12,,94.77068750000036,685.5,601.25,1996
2014,2014,1277,1996-11-05 18:00:00,151.5,12.0,N,WNP,1,987.9638,23.73143,1996,11,5,18,,-67.72021446077997,1303.875,1032.1875,1996
2015,2015,1277,1996-11-06 00:00:00,150.5,11.25,N,WNP,1,988.9825,22.13266,1996,11,6,0,,-69.76611607143423,1027.5,1026.25,1996
2016,2016,1277,1996-11-06 06:00:00,150.5,11.0,N,WNP,1,984.9306,20.68039,1996,11,6,6,,87.18475000000035,974.25,1047.5,1996
2017,2017,1277,1996-11-06 12:00:00,150.0,11.75,N,WNP,1,985.3925,24.90848,1996,11,6,12,,-9.67134868420544,907.5,1192.5,1996
2018,2018,1277,1996-11-06 18:00:00,148.75,11.5,N,WNP,1,982.3831,22.32405,1996,11,6,18,,-39.91001488095208,935.625,1071.25,1996
2019,2019,1277,1996-11-07 00:00:00,148.75,11.0,N,WNP,1,979.8469,24.26687,1996,11,7,0,,-35.49987500000134,1120.875,1337.498779296875,1996

The download_dale.nc is the ERA5 file, is downloaded using the API, as this:

import cdsapi
 
c = cdsapi.Client()
 
c.retrieve(
    'reanalysis-era5-pressure-levels',
    {
        'product_type': 'reanalysis',
        'variable': 'geopotential',
        'pressure_level': [
            '250',
            '300', '350', '400',
            '450', '500', '550',
            '600', '650', '700',
            '750', '800', '850',
            '900', '950'
        ],
        'year': '1996',
        'month': '11',
        'day': [
            '05', '06', '07',
            '08', '09', '10',
            '11', '12', '13',
        ],
        'time': [
            '00:00', '06:00', '12:00',
            '18:00',
        ],
        'area': [
             90, # north
            200, # west  
             -90, # south
            100, # east
        ],
        'format': 'netcdf',
    },
    'download_dale.nc')

And this the information about the snaps_Dale.nc file created by NodeFileCompose:

> R

R version 4.4.0 (2024-04-24) -- "Puppy Cup"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

> library(ncdf4)
> snaps <- ncdf4::nc_open("snaps_Dale.nc")
> summary(ncvar_get(snaps, 'snap_lat'))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   9.00   11.62   13.25   17.28   22.25   36.50 
> summary(ncvar_get(snaps, 'snap_lon'))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  130.8   133.8   141.0   141.3   148.8   155.0 
> summary(ncvar_get(snaps, 'r'))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  0.250   1.375   2.500   2.500   3.625   4.750 
> summary(ncvar_get(snaps, 'az'))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00   84.38  168.75  168.75  253.12  337.50 
> summary(ncvar_get(snaps, 'snap_zg'))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
     NA      NA      NA     NaN      NA      NA   84000 
> summary(ncvar_get(snaps, 'zg'))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
     NA      NA      NA     NaN      NA      NA    2400 
> snaps
File snaps_Dale.nc (NC_FORMAT_NETCDF4):

     6 variables (excluding dimension variables):
        int snap_pathid[snapshot]   (Contiguous storage)  
        double snap_lon[snapshot]   (Contiguous storage)  
            units: degrees_east
        double snap_lat[snapshot]   (Contiguous storage)  
            units: degrees_north
        int snap_time[snapshot]   (Contiguous storage)  
            units: hours since 1900-01-01 00:00:00.0
        float snap_zg[az,r,level,snapshot]   (Contiguous storage)  
            _FillValue: -32767
        float zg[az,r,level]   (Contiguous storage)  
            _FillValue: -32767

     4 dimensions:
        az  Size:16 
            name: stereographic azimuth angle
            units: degrees
        r  Size:10 
            name: stereographic great circle distance
            units: degrees
        snapshot  Size:35 (no dimvar)
        level  Size:15 (no dimvar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant