Exemple #1
0
 def test_valid_times(self):
     units = "hours since 1970-01-01 00:00:00"
     times = {
         "time_0": [dt.datetime(2019, 1, 1)],
         "time_1": [dt.datetime(2019, 1, 1, 3)]
     }
     with netCDF4.Dataset(self.path, "w") as dataset:
         um = tutorial.UM(dataset)
         for name, values in times.items():
             var = um.times(name, length=len(values))
             var[:] = netCDF4.date2num(values, units=var.units)
         var = um.pressures("pressure", length=1)
         var[:] = 1000.
         var = um.longitudes(length=1)
         var[:] = 125.
         var = um.latitudes(length=1)
         var[:] = 45.
         dims = ("time_1", "pressure", "longitude", "latitude")
         var = um.relative_humidity(dims)
         var[:] = 100.
     variable = "relative_humidity"
     coord = unified_model.Coordinates()
     result = coord.valid_times(self.path, variable)
     expect = times["time_1"]
     np.testing.assert_array_equal(expect, result)
Exemple #2
0
 def test_initial_time_given_forecast_reference_time(self):
     time = dt.datetime(2019, 1, 1, 12)
     with netCDF4.Dataset(self.path, "w") as dataset:
         um = tutorial.UM(dataset)
         um.forecast_reference_time(time)
     coords = unified_model.Coordinates()
     result = coords.initial_time(self.path)
     expect = time
     np.testing.assert_array_equal(expect, result)
Exemple #3
0
 def file_type(cls, paths, file_type):
     if file_type.lower() == "rdt":
         coordinates = rdt.Coordinates()
     elif file_type.lower() == "eida50":
         coordinates = eida50.Coordinates()
     elif file_type.lower() == 'griddedforecast':
         # XXX This needs a "Group" object ... not "paths"
         return gridded_forecast.Navigator(paths)
     elif file_type.lower() == "unified_model":
         coordinates = unified_model.Coordinates()
     else:
         raise Exception("Unrecognised file type: '{}'".format(file_type))
     return cls(paths, coordinates)
Exemple #4
0
 def from_file_type(cls, paths, file_type):
     if file_type.lower() == "rdt":
         coordinates = rdt.Coordinates()
     elif file_type.lower() == "eida50":
         coordinates = eida50.Coordinates()
     elif file_type.lower() == 'griddedforecast':
         # XXX This needs a "Group" object ... not "paths"
         return gridded_forecast.Navigator(paths)
     elif file_type.lower() == 'intake':
         return intake_loader.Navigator()
     elif file_type.lower() == 'ghrsstl4':
         return ghrsstl4.Navigator(paths)
     elif file_type.lower() == "unified_model":
         coordinates = unified_model.Coordinates()
     elif file_type.lower() == "saf":
         coordinates = saf.Coordinates()
     elif file_type.lower() == "earth_networks":
         coordinates = earth_networks.Coordinates()
     else:
         raise Exception("Unrecognised file type: '{}'".format(file_type))
     return cls(paths, coordinates)
Exemple #5
0
 def __init__(self, paths, coordinates=None):
     self.paths = paths
     if coordinates is None:
         coordinates = unified_model.Coordinates()
     self.coordinates = coordinates