bnlawrence / cfs

Rebooting cfstore, leaner and meaner
0 stars 0 forks source link

Fix time domain axis handling in cf parsing #25

Open bnlawrence opened 8 hours ago

bnlawrence commented 8 hours ago

I am seeing things like this Cell Methods: area : mean, domainaxis0 : point, domainaxis0 : mean in the CANARI cfs records. This must mean that the cf-parsing hasn't pushed the name of the axis through correctly.

bnlawrence commented 6 hours ago

Ok, I see this one is coming from field 686 (and others) in the CANARI file:

Data(time(780), air_pressure(36), latitude(325), longitude(1)) =  1

Cell Method: area: mean
Cell Method: time(780): mean (interval: 6 h)
Cell Method: longitude(1): mean

Domain Axis: air_pressure(36)
Domain Axis: latitude(325)
Domain Axis: longitude(1)
Domain Axis: time(780)

Dimension coordinate: time
    axis = 'T'
    calendar = '360_day'
    long_name = 'Time axis'
    standard_name = 'time'
    time_origin = '1950-01-01 00:00:00'
    units = 'seconds since 1950-01-01 00:00:00'
    Data(time(780)) = [1950-01-16 00:00:00, ..., 2014-12-16 00:00:00] 360_day
    Bounds:calendar = '360_day'
    Bounds:units = 'seconds since 1950-01-01 00:00:00'
    Bounds:Data(time(780), 2) = [[1950-01-01 00:00:00, ..., 2015-01-01 00:00:00]] 360_day

Dimension coordinate: air_pressure
    axis = 'Z'
    long_name = 'pressure levels'
    name = 'um_atmos_DP36CCMZ'
    positive = 'down'
    standard_name = 'air_pressure'
    units = 'hPa'
    Data(air_pressure(36)) = [1000.0, ..., 0.029999999329447746] hPa

Dimension coordinate: latitude
    axis = 'Y'
    long_name = 'Latitude'
    standard_name = 'latitude'
    units = 'degrees_north'
    Data(latitude(325)) = [-90.0, ..., 90.0] degrees_north
    Bounds:units = 'degrees_north'
    Bounds:Data(latitude(325), 2) = [[-90.0, ..., 90.0]] degrees_north

Dimension coordinate: longitude
    axis = 'X'
    long_name = 'Longitude'
    standard_name = 'longitude'
    units = 'degrees_east'
    Data(longitude(1)) = [179.5833384245634] degrees_east
    Bounds:units = 'degrees_east'
    Bounds:Data(longitude(1), 2) = [[-0.4166666567325592, 359.5833435058594]] degrees_east

And my code:

 for m, cm in v.cell_methods().items():
            for a in cm.get_axes():
                if hasattr(cm,'intervals'):
                    intervals = cm.intervals
                else:
                    intervals=None
                cmlist.append((a,cm.get_method(),cm.qualifiers(),intervals))

yields [('area',), ('domainaxis0',), ('domainaxis3',)] whereas for most of the other fields, it yields [('area',), ('time',)].

I'm going to guess that you can solve this instantly @davidhassell !

bnlawrence commented 6 hours ago

(This is fromf = cf.read('data/CANARI_1_cs125_atmos.cfa'))