pp-mo / ugrid-checks

UGRID file format compliance checking
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Negative TIME array values, OK? #70

Closed rduivenvoorde closed 10 months ago

rduivenvoorde commented 1 year ago

Working with people trying to run models which do backward predictions, the timesteps in the netcdf's are negative values: [0, -1, -2, ...]. So based on the data of t=0 == reference time, you can try to calculate data for t=-1 (1 hour ago)...

My issue is that I cannot find a viewer yet, which can handle that. Some do handle negative values in natural order: [..., -2, -1, 0]...

Wondering IF it should be possible, I tried ugrid-checks, and ugrid-checks is FINE with it both :-)

My question now: SHOULD it be fine or isn't it defined in the specs.

Any nc guru's around here? Thanks for any input, but feel free to close...

pp-mo commented 1 year ago

I guess your -ve values are in a time coordinate ? There should be nothing "special" about that, but I guess it depends on your viewer.

In any case, this is not really a UGRID issue at all, more CF conventions maybe.

The regular way to record time in CF is as a time-offset value related to a start-time and calendar, which is given in the "units" attribute. Here's the CDL of a (tiny) complete file ...

netcdf tmp {
dimensions:
    time = 3 ;
variables:
    int64 unknown(time) ;
    double time(time) ;
        time:axis = "T" ;
        time:units = "days since 2001-01-01" ;
        time:standard_name = "time" ;
        time:calendar = "standard" ;

// global attributes:
        :Conventions = "CF-1.7" ;
data:

 unknown = 0, 1, 2 ;

 time = -2, -1, 0 ;
}

I don't think there is anything special about a time coordinate -- no reason it should not have negative values.

In any case, this isn't a UGRID issue at all.
But ugrid-checks doesn't in any case check CF conformances -- that's kind of a separate space. So, you could try also running your data through the cf-checker (here, and in the online version) to see if there is some other problem lurking.

pp-mo commented 1 year ago

Failing that, try another viewer !

We are using Iris and Geovista, quick intro here. That may well be total overkill for you, but if not we'd welcome any feedback !!

pp-mo commented 1 year ago

running your data through the cf-checker (here, and in the online version) t

I think the usual link is down. There is this alternative : https://compliance.ioos.us/index.html I don't know much about it

rduivenvoorde commented 1 year ago

The regular way to record time in CF is as a time-offset value related to a start-time and calendar, which is given in the "units" attribute. Here's the CDL of a (tiny) complete file ...


netcdf tmp {
 time = -2, -1, 0 ;
}

Thanks for all the information! Viewers I used are Panoply and QGIS (I'm into geo ...) We are combining all kind of realtime information on top of the netcdf data.

One of our issues is that time is 'reverse': you first calculate the t=0 situation (and write to nc), then you do t=-1 and write etc etc Which makes the time array not: [-2,1,0] like in the example above, but [0,-1,-2 etc]. Maybe that causes the most problems...

Again: thanks for anwering!

pp-mo commented 10 months ago

Just reviewing old issues -- looks like this is ok to close @rduivenvoorde ?

If not, please feel free to re-open.