def setUp(self): cdltext = r"""netcdf charvars { dimensions: nreg = 3 ; namelen = 10 ; rec = 2 ; code = 3 ; codelen = 4 ; variables: char letter ; int regcodes(nreg) ; regcodes:long_name = "region codes" ; char regions(nreg, namelen) ; regions:long_name = "region names" ; char digits(namelen) ; digits:long_name = "decimal digits" ; int sampleid(rec) ; sampleid:long_name = "sample id" ; char dna_code(rec, code, codelen) ; dna_code:long_name = "DNA code" ; // global attributes :comment = "a cast of unholy characters" ; data: regcodes = 1, 2, 3 ; regions = "Europe", "Americas", "Asia" ; digits = "0123456789" ; letter = "X" ; sampleid = 1, 2 ; dna_code = "ACTG", "ACGG", "ATGC", "CTGA", "GCTA", "TGCA"; }""" parser = cdlparser.CDL3Parser() self.tmpfile = tempfile.mkstemp(suffix='.nc')[1] self.dataset = parser.parse_text(cdltext, ncfile=self.tmpfile)
def setUp(self): cdltext = r"""netcdf fillvalues { dimensions: lat = 2 ; lon = 2 ; time = unlimited ; variables: int time(time) ; time:units = "days since 1970-01-01" ; float lat(lat) ; lat:standard_name = "latitude" ; float lon(lon) ; lon:standard_name = "longitude" ; float tas(time, lat, lon) ; tas:standard_name = "air_temperature" ; tas:_FillValue = -1.0e30f ; // global attributes :comment = "fill value tests" ; data: time = 0, 30, 60 ; lat = 0.0f, 10.0f ; lon = 0.0f, 20.0f ; // final 2 values are missing from tas data array and thus // should be automatically assigned as fill values tas = _, _, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f ; }""" parser = cdlparser.CDL3Parser() self.tmpfile = tempfile.mkstemp(suffix='.nc')[1] self.dataset = parser.parse_text(cdltext, ncfile=self.tmpfile)
def setUp(self) : cdltext = r"""netcdf constants { dimensions: dim1 = 3 ; variables: float var1(dim1) ; var1:att1 = "dummy attribute" ; // FillValue necessary to enable masking in NETCDF3_CLASSIC right now. // See https://github.com/Unidata/netcdf4-python/issues/725. var1:_FillValue = 9.9692099683868690e+36; // global attributes :c1 = "foo" ; // with spaces :c2="bar" ; // w/o spaces :byte1 = 123b ; :byte2 = 'a' ; // 97 :byte3 = '\n' ; // 10 :short1 = 1234s ; :short2 = -888s ; :short3 = 0xFFs ; // 255 :short4 = 077s ; // 63 :int1 = -56789 ; :int2 = 123456 ; :int3 = 0666 ; // 438 :int4 = 0x2F ; // 47 :iarray = 1, 2, 3, 4 ; :float1 = 123.0f ; :float2 = 0.2718e1f ; :farray = 1.0f, 2.0f, 3.0f ; :double1 = 3.14159d ; :double2 = 0.010203 ; :darray = 1.0, 2.0, 3.0 ; data: var1 = 1.0f, 2.0f, _ ; }""" parser = cdlparser.CDL3Parser() self.tmpfile = tempfile.mkstemp(suffix='.nc')[1] self.dataset = parser.parse_text(cdltext, ncfile=self.tmpfile)
def setUp(self): cdltext = r"""netcdf constants { dimensions: dim1 = 3 ; variables: float var1(dim1) ; var1:att1 = "dummy attribute" ; // global attributes :c1 = "foo" ; // with spaces :c2="bar" ; // w/o spaces :byte1 = 123b ; :byte2 = 'a' ; // 97 :byte3 = '\n' ; // 10 :short1 = 1234s ; :short2 = -888s ; :short3 = 0xFFs ; // 255 :short4 = 077s ; // 63 :int1 = -56789 ; :int2 = 123456 ; :int3 = 0666 ; // 438 :int4 = 0x2F ; // 47 :iarray = 1, 2, 3, 4 ; :float1 = 123.0f ; :float2 = 0.2718e1f ; :farray = 1.0f, 2.0f, 3.0f ; :double1 = 3.14159d ; :double2 = 0.010203 ; :darray = 1.0, 2.0, 3.0 ; data: var1 = 1.0f, 2.0f, _ ; }""" parser = cdlparser.CDL3Parser() self.tmpfile = tempfile.mkstemp(suffix='.nc')[1] self.dataset = parser.parse_text(cdltext, ncfile=self.tmpfile)
def setUp(self): cdltext = r"""netcdf basics { dimensions: lev = 1 ; lat = 2 ; lon = 3 ; time = unlimited ; variables: int tas(lev, lat, lon) ; tas:standard_name = "air_temperature" ; tas:units = "K" ; tas:radius = 6371000.0 ; double height(lev) ; height:standard_name = "height" ; // global attributes :Conventions = "CF-1.5" ; :comment = "cdlparser rocks!" ; data: tas = 0, 1, 2, 3, 4, 5 ; height = 10.0 ; }""" parser = cdlparser.CDL3Parser() self.tmpfile = tempfile.mkstemp(suffix='.nc')[1] self.dataset = parser.parse_text(cdltext, ncfile=self.tmpfile)