[ncl-talk] Adding time coordinate

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Tue Jan 12 12:39:18 MST 2021


Okay.  It looks like your original dates and times are not regularly
spaced, and you are trying to make a new set of time coordinates by setting
seconds = 0.  This results in more irregular time values with some
duplicate values, which are not legal for coordinate subscripting.  This is
the error "Non-monotonic coordinate value".

It looks like your input file spans all 24 hours in one day.  Can you
please explain exactly what you want the new time coordinates to look
like?  Are they regularly spaced or irregular?  Start and end times?


On Tue, Jan 12, 2021 at 4:51 AM Vanúcia Schumacher <
vanucia-schumacher at hotmail.com> wrote:

> Using your sugestion:
> ntimes = dimsizes(time)
> new_data = new((/nlat,mlon,ntimes/),"float")
> I got this error:
> fatal:NclOneDValGetClosestIndex: Non-monotonic coordinate value being
> used, can't complete coordinate subscript
> fatal:Could not obtain coordinate indexes, unable to perform subscript
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 89 in
> file test.ncl
> The line 89:   new_data({lat(i)},{lon(i)},{time(i)}) =
> new_data({lat(i)},{lon(i)},{time(i)})+(/var(i)/)
>
> Using this:
> ntimes = dimsizes(time(1))
> new_data = new((/nlat,mlon,ntimes/),"float")
> I got this error:
> fatal:Coordinate variables must be the same dimension as their dimension
> fatal:No coordinate variable exists for dimension (time) in variable
> (new_data)
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 86 in
> file test.ncl
> The line 86: new_data&time     = time
>
> Attached is the script and a test data.
> Thanks
> ------------------------------
> *De:* Dave Allured - NOAA Affiliate <dave.allured at noaa.gov>
> *Enviado:* segunda-feira, 11 de janeiro de 2021 22:55
> *Para:* Vanúcia Schumacher <vanucia-schumacher at hotmail.com>
> *Cc:* ncl-talk at ucar.edu <ncl-talk at ucar.edu>
> *Assunto:* Re: [ncl-talk] Adding time coordinate
>
> Please show the complete text for line 75, the complete error message, and
> printVarSummary for the array new_data, just before line 75 is executed.
> Also please attach the current version of your script.  Thank you.
>
>
> On Mon, Jan 11, 2021 at 5:39 PM Vanúcia Schumacher <
> vanucia-schumacher at hotmail.com> wrote:
>
> Thanks for the help, but the error persists in the line 75
>
> PrintVarSummary:
>
> Variable: nlat
> Type: integer
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
>
> Variable: mlon
> Type: integer
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
>
> Variable: ntimes
> Type: integer
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 6024
>
> *De:* Dave Allured - NOAA Affiliate <dave.allured at noaa.gov>
> *Enviado:* segunda-feira, 11 de janeiro de 2021 20:27
> *Para:* Vanúcia Schumacher <vanucia-schumacher at hotmail.com>
> *Cc:* ncl-talk at ucar.edu <ncl-talk at ucar.edu>
> *Assunto:* Re: [ncl-talk] Adding time coordinate
>
> Your script looks pretty good so far.  This does not look right:
>     new_data = new((/nlat,mlon,toint(time(1))/),"float")
>
> Try this:
>     ntimes = dimsizes (time)
>     new_data = new((/nlat,mlon,ntimes/),"float")
>
> Always use printVarSummary when you are having problems with arrays; and
> look at dimensions, coordinates, attributes, and such.
>
> Also, in the future, please show the *first* error received, and be sure
> to show exactly which line it occurs on.  Usually the first error causes
> more problems later, and it is harder to sort out.  I am not sure what
> happened this time, but that does not matter now.  Good luck.
>
>
> On Mon, Jan 11, 2021 at 2:51 PM Vanúcia Schumacher via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
> Hi users,
>
> I need to add the time information (preference in hh and mn) extracted
> from an ascii file to a new variable (new_data from script), but I am not
> having success.
> Attached is the script I am trying using the function cd_inv_calendar and
> the error obtained:
> fatal:No coordinate variable exists for dimension (time) in variable
> (new_data)
>
> I appreciate some help to attach this information to my new variable
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210112/86ab349a/attachment.html>


More information about the ncl-talk mailing list