def test_heat_wave_frequency(client, tasmin_dataset, tasmax_dataset): identifier = "heat_wave_frequency" inputs = [ wps_input_file("tasmax", tasmax_dataset), wps_input_file("tasmin", tasmin_dataset), ] outputs = execute_process(client, identifier, inputs) ds = xr.open_dataset(outputs[0]) assert ds.heat_wave_frequency.standard_name == _get_output_standard_name( identifier)
def test_wps_averagepoly(client, netcdf_datasets): # --- given --- identifier = "average_polygon" poly = { "type": "Feature", "id": "apolygon", "geometry": { "type": "Polygon", "coordinates": [[[0.5, 0], [2.5, 0], [2.5, 2.5], [0.5, 2.5]]], }, } inputs = [ wps_input_file("resource", f"file://{netcdf_datasets['tasmin']}"), wps_literal_input("shape", geojson.dumps(poly)), wps_literal_input("variable", "tasmin"), wps_literal_input("start_date", "2000"), ] # --- when --- outputs = execute_process(client, identifier, inputs) # --- then --- ds = xr.open_dataset(outputs[0]) assert ds.geom.size == 1 assert ds.id.values == ["apolygon"]
def test_tg_mean(client, tas_dataset): identifier = "tg_mean" inputs = [wps_input_file("tas", tas_dataset)] outputs = execute_process(client, identifier, inputs) ds = xr.open_dataset(outputs[0]) assert ds.tg_mean.standard_name == _get_output_standard_name(identifier)
def test_wps_subsetpoly_shapefile(client, netcdf_datasets): # --- given --- identifier = "subset_polygon" poly = shapefile_zip() inputs = [ wps_input_file("resource", f"file://{netcdf_datasets['tasmin']}"), wps_input_file("shape", poly), wps_literal_input("variable", "tasmin"), wps_literal_input("start_date", "2000"), ] # --- when --- outputs = execute_process(client, identifier, inputs) # --- then --- ds = xr.open_dataset(outputs[0]) assert list(ds.lat.values) == [0, 1, 2] assert list(ds.lon.values) == [1, 2]
def test_wps_averagepoly_shapefile(client, netcdf_datasets, tolerance): # --- given --- identifier = "average_polygon" poly = shapefile_zip() inputs = [ wps_input_file("resource", f"file://{netcdf_datasets['tasmin']}"), wps_input_file("shape", poly), wps_literal_input("tolerance", tolerance), wps_literal_input("variable", "tasmin"), wps_literal_input("start_date", "2000"), ] # --- when --- outputs = execute_process(client, identifier, inputs) # --- then --- ds = xr.open_dataset(outputs[0]) assert ds.geom.size == 1 assert ds.FID.values == [0]
def test_heat_wave_index(client, tasmax_dataset): identifier = "hwi_{thresh}" inputs = [ wps_input_file("tasmax", tasmax_dataset), wps_literal_input("thresh", "30 degC"), ] outputs = execute_process(client, identifier, inputs) ds = xr.open_dataset(outputs[0]) assert ds["hwi_30 degC"].standard_name == _get_output_standard_name( identifier)