Skip to content

Commit

Permalink
WIP: add unittest for pressure vertical coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
mhidas committed Aug 4, 2016
1 parent 72943ce commit 4607558
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
netcdf test {
dimensions:
PRES = 16 ;
variables:
double TIME ;
TIME:standard_name = "time" ;
TIME:units = "days since 1950-01-01 00:00:00 UTC" ;
TIME:axis = "T" ;
double LATITUDE ;
LATITUDE:standard_name = "latitude" ;
LATITUDE:units = "degrees_north" ;
LATITUDE:axis = "Y" ;
double LONGITUDE ;
LONGITUDE:standard_name = "longitude" ;
LONGITUDE:units = "degrees_east" ;
LONGITUDE:axis = "X" ;
double PRES(PRES) ;
PRES:standard_name = "sea_water_pressure" ;
PRES:units = "dbar" ;
PRES:axis = "Z" ;
double TEMP(PRES) ;
TEMP:standard_name = "sea_water_temperature" ;
TEMP:units = "Celsius" ;
TEMP:_FillValue = 999999. ;
TEMP:coordinates = "TIME LATITUDE LONGITUDE PRES" ;

// global attributes:
:geospatial_lat_min = -64.0937 ;
:geospatial_lat_max = -64.0937 ;
:geospatial_lon_min = 91.0651 ;
:geospatial_lon_max = 91.0651 ;
:geospatial_vertical_min = 4. ;
:geospatial_vertical_max = 502. ;
:geospatial_vertical_units = "dbar" ;
:time_coverage_start = "2013-03-02T01:20:00Z" ;
:time_coverage_end = "2013-03-02T01:20:00Z" ;

data:

TIME = 23071.0555555556 ;

LATITUDE = -64.0937 ;

LONGITUDE = 91.0651 ;

PRES =
4,
10,
20,
30,
42,
50,
62,
100,
122,
200,
230,
300,
354,
400,
500,
502 ;

TEMP =
0.4852,
0.4903,
0.5082,
0.3958,
-0.6897,
-1.0447,
-1.249,
-1.1698,
-1.2056,
0.0152,
0.5848,
0.973,
1.305,
1.2744,
1.2207,
1.2207 ;
}
1 change: 1 addition & 0 deletions lib/cc_plugin_imos/cc_plugin_imos/tests/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ def generate_dataset(cdl_path, nc_path):
'data_var' : get_filename('tests/data/imos_data_var.nc'),
'bad_coords' : get_filename('tests/data/imos_bad_coords.nc'),
'new_data' : get_filename('tests/data/imos_new_data.nc'),
'pressure_coord': get_filename('tests/data/imos_pressure_coord.nc'),
}
15 changes: 15 additions & 0 deletions lib/cc_plugin_imos/cc_plugin_imos/tests/test_imos.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def setUp(self):
self.data_variable_dataset = self.load_dataset(STATIC_FILES['data_var'])
self.bad_coords_dataset = self.load_dataset(STATIC_FILES['bad_coords'])
self.new_dataset = self.load_dataset(STATIC_FILES['new_data'])
self.pressure_coord_dataset = self.load_dataset(STATIC_FILES['pressure_coord'])

#--------------------------------------------------------------------------------
# Compliance Tests
Expand Down Expand Up @@ -297,6 +298,14 @@ def test_vertical_coordinate_type(self):
var = MockVariable('NONAME', axis='Z')
self.assertEqual(util.vertical_coordinate_type(self.good_dataset, var), 'unknown')

def test_vertical_coordinate_type_pressure(self):
var = MockVariable('NONAME', standard_name='sea_water_pressure')
self.assertIsNone(util.vertical_coordinate_type(self.pressure_coord_dataset, var))
var = MockVariable('NONAME', standard_name='sea_water_pressure', axis='Z')
self.assertEqual(util.vertical_coordinate_type(self.pressure_coord_dataset, var), 'pressure')
var = self.pressure_coord_dataset.variables['PRES']
self.assertEqual(util.vertical_coordinate_type(self.pressure_coord_dataset, var), 'pressure')



### Test compliance checks
Expand Down Expand Up @@ -638,6 +647,12 @@ def test_check_vertical_variable(self):
self.assertIn(result.name[1], ('DEPTH', 'NOMINAL_DEPTH'))
self.assertTrue(result.value)

ret_val = self.imos.check_vertical_variable(self.pressure_coord_dataset)
self.assertGreater(len(ret_val), 0)
for result in ret_val:
self.assertEqual(result.name[1], 'PRES')
self.assertTrue(result.value)

ret_val = self.imos.check_vertical_variable(self.bad_coords_dataset)
self.assertEqual(len(ret_val), 23)
for result in ret_val:
Expand Down

0 comments on commit 4607558

Please sign in to comment.