[Thread Prev][Thread Next][Index]

Re: [ferret_users] DAYS1900 function not working as I expect




Thanks to Billy and Ainsley. I had a mental block and couldn't see the problem.

I've got the data the way I want. Thanks!


On Thu, Feb 23, 2023 at 11:56 AM William Kessler - NOAA Federal <william.s.kessler@xxxxxxxx> wrote:

The very first thing to do would be to test your read by listing the first few values of mon,day,hour,minute,data:
LIST/I=1:30 mon,day,hour,minute,data   ! Noting more than 24 points to test HR. Is this correct?

Two possibilities come to mind:

1) Since you do not specify the axes/grid of the input, Ferret is taking it along the x-axis, not the time axis as you want. Apparently DAYS1900 is just reading the numbers so it works at least partly but I think everything would be smoother (especially later if you want to plot on a time axis) if you defined the time axis and grid right at the start with DEFINE AXIS and then DEFINE GRID, then read the data with FILE/.../GRID=

If you know the time range and axis exactly - and since you have a small number of records - you can define the time axis from looking at the raw data. Otherwise, if you know that the time axis is regular you could use that information.
Or, you can do a double read:
First read ingests MON,DAY,HR,MIN and uses that to construct the axis and grid. Then use those for the second (actual) read on the defined grid. Using the same file, the second read will simply replace the first, and the axes/grid defined from the first read will remain defined.

2) Define a fortran format for your read. The problem might be the integer values of MON,DAY,HR,MIN. But you can fake it with a fortran format with zero decimal places:
FILE/FORMAT=(f3.0,f4.0,f5.0,f4.0,f5.1) ... ! I think this will read your MON,DAY,HR,MIN,DATA

Billy


On Thu, Feb 23, 2023 at 10:01 AM Gary Strand <strandwg@xxxxxxxx> wrote:

I have some 5-minute data for an entire month that I'm trying to read in and save as netCDF and the DAYS1900 function doesn't appear to be incrementing the date as I expect.

Here's a data sample, two days' worth (24 samples)

mon day hour min data
  1   1    0   0 13.4
  1   1    0   5 13.1
  1   1    0  10 12.7
  1   1    0  15 12.2
  1   1    0  20 11.9
  1   1    0  25 11.5
  1   1    0  30 11.3
  1   1    0  35 11.0
  1   1    0  40 10.8
  1   1    0  45 10.7
  1   1    0  50 10.5
  1   1    0  55 10.3
  1   1    1   0 10.1
  1   1    1   5 10.1
  1   1    1  10 10.0
  1   1    1  15 9.8
  1   1    1  20 9.7
  1   1    1  25 9.6
  1   1    1  30 9.6
  1   1    1  35 9.6
  1   1    1  40 9.5
  1   1    1  45 9.4
  1   1    1  50 9.4
  1   1    1  55 9.3


And part of a script to read the data:

[...]
file/skip=1/var=mon,day,hour,minute,data $1
!
let time = (DAYS1900(2022,mon,day)-DAYS1900(2022,1,1))+(hour/24)+(minute/60)
list time
[...]
And the output of "list time":

             VARIABLE : (DAYS1900(2022,MON,DAY)-DAYS1900(2022,1,1))+(HOUR/24)+(MINUTE/60)
             FILENAME : TEST
             SUBSET   : 24 points (X)
 1     /   1:  0.000
 2     /   2:  0.083
 3     /   3:  0.167
 4     /   4:  0.250
 5     /   5:  0.333
 6     /   6:  0.417
 7     /   7:  0.500
 8     /   8:  0.583
 9     /   9:  0.667
 10    /  10:  0.750
 11    /  11:  0.833
 12    /  12:  0.917
 13    /  13:  0.042
 14    /  14:  0.125
 15    /  15:  0.208
 16    /  16:  0.292
 17    /  17:  0.375
 18    /  18:  0.458
 19    /  19:  0.542
 20    /  20:  0.625
 21    /  21:  0.708
 22    /  22:  0.792
 23    /  23:  0.875
 24    /  24:  0.958

Why is the 13th sample not 1.042? Of course, ferret is complaining that the axis isn't monotonically increasing.

What am I missing?

Thanks!

--
Gary Strand, CESM Data Manager
ORCID 0000-0001-9740-0104
strandwg@xxxxxxxx


--
Gary Strand, CESM Data Manager
ORCID 0000-0001-9740-0104
strandwg@xxxxxxxx

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement