[ncl-talk] converting 360 day calendar to 365 day (standard) calendar
Gus Correa
gus at ldeo.columbia.edu
Sun Feb 24 16:44:15 MST 2019
Have you tried to define zg_new dimensions and metadata before you use it
on the r.h.s. of linint1_n?
Something like this:
zg_new=new( (/ time_steps, dimsizes(lat), dimsizes(lon) /), "float",
1.0e+20 )
Then the part of the code where you define zg_new metadata:
zg_new!0 = "time"
zg_new&time = time_365
zg_new!1 = "lat"
zg_new&lat = lat
zg_new!2 = "lon"
zg_new&lon = lon
zg_new at _FillValue = 1.0e+20
zg_new at missing_value = 1.0e+20
zg_new at standard_name = "geopotential_height"
zg_new at long_name = "Geopotential Height"
zg_new at units = "m"
zg_new at coordinates = "lon lat plev" < Why time is not
included? Why plev is included?
zg_new at cell_methods = "time: maximum" <- Why maximum if your original
data says mean?
And only then the interpolation.
The extra (/ ... /) parenthesis on the l.h.s. prevent inheriting the
metadata from "var".
The rm_single_dims is to remove the degenerate (dimension=1) "plev" of
"var", making it 3D (not 4D anymore).
Also, var is multidimensional, so I think the arguments of linint1_n need
to honor that:
zg_new = (/ linint1_n( (/ time_360, lat, lon /),
rm_single_dims(var), False, (/ time_365, lat, lon/), 0, 0) /)
I haven't tested it, so it goes with no guarantees.
I hope this helps.
On Sun, Feb 24, 2019 at 5:31 PM Kwesi A. Quagraine <starskykwesi at gmail.com>
wrote:
> Hello NCLers
>
> I am trying to convert a netcdf file with 360 day calendar to standard,
> 365 day calendar with the script below; I am having errors when I try. I
> will be grateful for any help.
>
> For printVarSummary;
>
> Variable: var
> Type: float
> Total Size: 37013760 bytes
> 9253440 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 12240] x [plev | 1] x [lat | 36] x [lon |
> 21]
> Coordinates:
> time: [43590.5..55829.5]
> plev: [70000..70000]
> lat: [-44.375..-0.625]
> lon: [6.5625..44.0625]
> Number Of Attributes: 9
> standard_name : geopotential_height
> long_name : Geopotential Height
> units : m
> _FillValue : 1e+20
> missing_value : 1e+20
> original_name : mo: m01s30i207/m01s30i301
> cell_methods : time: mean
> history : 2012-06-26T08:31:01Z altered by CMOR: replaced missing value
> flag (-1.07374e+09) with standard missing value (1e+20).
> associated_files : baseURL:
> http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile:
> gridspec_atmos_fx_HadGEM2-ES_historical_r0i0p0.nc
>
> fatal:Coordinate variables must be the same dimension as their dimension
> fatal:No coordinate variable exists for dimension (lat) in variable
> (zg_new)
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 25 in file
>
>
> For Script:
> f = addfile("zg700_day_HadGEM2-ES_rcp85_r1i1p1_19800101-20131231.nc","r")
> var = f->zg
> time_360 = var&time
> lat = f->lat
> lon = f->lon
> plev = f->plev
> printVarSummary(var)
>
> time_steps = 34*365 ;1980 to 2013
> time_365 = fspan(1,time_steps,time_steps)
> time_365!0 = "time"
> time_365&time = time_365
> time_365 at standard_name = "time"
> time_365 at units = "days since 1980-01-01 12:00:00"
> time_365 at calendar = "365_day"
> time_365 at long_name = "time"
> time_365 at axis = "T"
>
> zg_new = linint1_n(time_360,var,False,time_365,0,0)
> zg_new!0 = "time"
> zg_new&time = time_365
> zg_new!1 = "lat"
> zg_new&lat = lat
> zg_new!2 = "lon"
> zg_new&lon = lon
>
> zg_new at _FillValue = 1.0e+20
> zg_new at missing_value = 1.0e+20
> zg_new at standard_name = "geopotential_height"
> zg_new at long_name = "Geopotential Height"
> zg_new at units = "m"
> zg_new at coordinates = "lon lat plev"
> zg_new at cell_methods = "time: maximum"
> printVarSummary(zg_new)
>
> ;system("rm -rf
> zg700_day_HadGEM2-ES_rcp85_r1i1p1_19800101-20131231_cal.nc")
> outf =
> addfile("zg700_day_HadGEM2-ES_rcp85_r1i1p1_19800101-20131231_cal.nc","c")
> outf->lat = lat
> outf->lon = lon
> outf->plev = plev
> outf->zg = zg_new
>
> I will be grateful for any help on this.
>
> Thanks
> Kwesi
> ------------
> Try not to become a man of success but rather a man of value- Albert
> Einstein
>
> Kwesi A. Quagraine
> Department of Physics
> School of Physical Sciences
> College of Agriculture and Natural Sciences
> University of Cape Coast
> Cape Coast, Ghana
>
> Alt. Email: kwesi at csag.uct.ac.za
> Web: http://www.recycleupghana.org/
> Office: +27 21 650 3164
> Skype: quagraine_cwasi
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190224/028eabc3/attachment.html>
More information about the ncl-talk
mailing list