Пример #1
0
 def do_subset(self, filename, time_min, time_max, variable):
     arguments = [
         'subset', variable + ':' + escape_colons(filename),
         't=[%s,%s]' % (time_min, time_max), '-o', self.OUTPUT_FILENAME
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
Пример #2
0
 def do_subset(self, filename, variable, aux_bounds):
     # Join the bounds with a comma if they are both specified
     arguments = [
         'subset', variable + ':' + escape_colons(filename), aux_bounds,
         '-o', self.OUTPUT_FILENAME
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
Пример #3
0
 def do_subset(self, filename, lat_max, lat_min, lon_max, lon_min, variable):
     arguments = [
         "subset",
         variable + ":" + filename,
         "x=[%s,%s],y=[%s,%s]" % (lon_min, lon_max, lat_min, lat_max),
         "-o",
         self.OUTPUT_NAME,
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
Пример #4
0
 def test_plot_gridded_2d_with_flattened_time(self):
     variable = valid_cis_gridded_output_variable
     filename = valid_cis_gridded_output_filename
     args = ['subset', variable + ':' + filename, 't=[2007-06-07T15]', '-o', self.OUTPUT_FILENAME]
     args = parse_args(args)
     subset_cmd(args)
     out_name = '3d_out.png'
     args = ['plot', variable + ':' + self.OUTPUT_FILENAME, '-o', out_name]
     main_arguments = parse_args(args)
     plot_cmd(main_arguments)
Пример #5
0
 def test_subset_NCAR_RAF_with_named_time_variable(self):
     # Takes 4s
     filename = valid_NCAR_NetCDF_RAF_filename
     variable = "LATC,LONC,GGALTC,Time,PSXC,WSC,ATX,ATHR2,CONCD_LWI"
     time_min, time_max = '2009-01-14T20:15:00', '2009-01-15T02:45:00'
     arguments = ['subset', variable + ':' + escape_colons(filename), 'time=[%s,%s]' % (time_min, time_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_temporal_subsetting(time_min, time_max)
     self.check_output_contains_variables(self.OUTPUT_FILENAME, variable.split(','))
Пример #6
0
 def test_GIVEN_single_variable_as_var_name_in_gridded_file_WHEN_subset_THEN_subsetted_correctly(self):
     variable = valid_hadgem_variable
     filename = valid_hadgem_filename
     lon_min, lon_max = 0, 10
     lat_min, lat_max = 40, 60
     arguments = ['subset', variable + ':' + escape_colons(filename),
                  'longitude=[%s,%s],latitude=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min, 'lat', 'lon')
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable])
Пример #7
0
 def test_GIVEN_single_variable_in_ungridded_file_WHEN_subset_THEN_subsetted_correctly(self):
     variable = valid_aerosol_cci_variable
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     arguments = ['subset', variable + ':' + escape_colons(filename),
                  'x=[%s,%s],y=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min)
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable])
Пример #8
0
 def do_subset(self, filename, variable, alt_bounds='', pres_bounds=''):
     # Join the bounds with a comma if they are both specified
     joint_bounds = ','.join([
         alt_bounds, pres_bounds
     ]) if alt_bounds and pres_bounds else alt_bounds or pres_bounds
     arguments = [
         'subset', variable + ':' + escape_colons(filename), joint_bounds,
         '-o', self.OUTPUT_FILENAME
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
Пример #9
0
 def test_GIVEN_shape_WHEN_subset_ungridded_data_THEN_subsetted_correctly(self):
     variable = valid_aerosol_cci_variable
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     shape_wkt = "POLYGON((-10 50, 0 60, 10 50, 0 40, -10 50))"
     arguments = ['subset', variable + ':' + escape_colons(filename),
                  'shape=%s' % shape_wkt, '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min)
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable])
Пример #10
0
    def test_subset_ECHAM_over_0_360_boundary_plots_OK(self):
        var = valid_echamham_variable_1
        filename = valid_echamham_filename
        args = ['subset', var + ':' + filename, 'x=[-10,10]', '-o', self.OUTPUT_FILENAME]
        args = parse_args(args)
        subset_cmd(args)
        out_name = 'subset_echam_boundary.png'
        args = ['plot', var + ":" + self.OUTPUT_FILENAME, '--type', 'contourf', '-o', out_name]
        args = parse_args(args)
        plot_cmd(args)

        os.remove(out_name)
Пример #11
0
 def test_GIVEN_multiple_variables_in_ungridded_file_WHEN_subset_THEN_subsetted_correctly(self):
     variable1 = valid_aerosol_cci_variable
     variable2 = valid_aerosol_cci_variable_2
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     arguments = ['subset', variable1 + ',' + variable2 + ':' + filename,
                  'x=[%s,%s],y=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min)
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable1, variable2])
Пример #12
0
 def test_GIVEN_multiple_variables_in_gridded_file_WHEN_subset_THEN_subsetted_correctly(self):
     variable1 = valid_echamham_variable_1
     variable2 = valid_echamham_variable_2
     filename = valid_echamham_filename
     lon_min, lon_max = 0, 10
     lat_min, lat_max = 40, 60
     arguments = ['subset', variable1 + ',' + variable2 + ':' + escape_colons(filename),
                  'x=[%s,%s],y=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min, 'lat', 'lon')
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable1, variable2])
Пример #13
0
 def test_GIVEN_variables_specified_by_wildcard_WHEN_subset_THEN_subsetted_correctly(self):
     variable1 = 'surface_albedo???'
     variable2 = 'AOD*'
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     arguments = ['subset', variable1 + ',' + variable2 + ':' + escape_colons(filename),
                  'x=[%s,%s],y=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min)
     self.check_output_contains_variables(self.OUTPUT_FILENAME, ['AOD550', 'AOD870', 'surface_albedo550',
                                                                           'surface_albedo670', 'surface_albedo870'])
Пример #14
0
 def test_subset_NCAR_RAF_with_named_time_variable(self):
     # Takes 4s
     filename = valid_NCAR_NetCDF_RAF_filename
     variable = "LATC,LONC,GGALTC,Time,PSXC,WSC,ATX,ATHR2,CONCD_LWI"
     time_min, time_max = '2009-01-14T20:15:00', '2009-01-15T02:45:00'
     arguments = [
         'subset', variable + ':' + escape_colons(filename),
         'time=[%s,%s]' % (time_min, time_max), '-o', self.OUTPUT_FILENAME
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_temporal_subsetting(time_min, time_max)
     self.check_output_contains_variables(self.OUTPUT_FILENAME,
                                          variable.split(','))
Пример #15
0
 def test_GIVEN_shape_WHEN_subset_ungridded_data_THEN_subsetted_correctly(
         self):
     variable = valid_aerosol_cci_variable
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     shape_wkt = "POLYGON((-10 50, 0 60, 10 50, 0 40, -10 50))"
     arguments = [
         'subset', variable + ':' + escape_colons(filename),
         'shape=%s' % shape_wkt, '-o', self.OUTPUT_FILENAME
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min)
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable])
Пример #16
0
 def test_GIVEN_single_variable_as_var_name_in_ungridded_file_WHEN_subset_THEN_subsetted_correctly(
         self):
     variable = valid_aerosol_cci_variable
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     arguments = [
         'subset', variable + ':' + escape_colons(filename),
         'lon=[%s,%s],lat=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max),
         '-o', self.OUTPUT_FILENAME
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min)
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable])
Пример #17
0
 def test_GIVEN_single_variable_in_gridded_file_WHEN_subset_THEN_subsetted_correctly(self):
     variable = valid_hadgem_variable
     filename = valid_hadgem_filename
     lon_min, lon_max = 0, 10
     lat_min, lat_max = 40, 60
     arguments = [
         "subset",
         variable + ":" + filename,
         "x=[%s,%s],y=[%s,%s]" % (lon_min, lon_max, lat_min, lat_max),
         "-o",
         self.OUTPUT_NAME,
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min, True)
     self.check_output_contains_variables(self.GRIDDED_OUTPUT_FILENAME, [variable])
Пример #18
0
 def test_GIVEN_multiple_gridded_variables_on_different_grids_WHEN_subset_THEN_subset_correctly(self):
     variable1 = 'v_1'
     variable2 = 'rh'
     filename = valid_1d_filename
     lat_min, lat_max = 40, 60
     arguments = ['subset', variable1 + ',' + variable2 + ':' + filename,
                  'y=[%s,%s]' % (lat_min, lat_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.ds = Dataset(self.OUTPUT_FILENAME)
     lat = self.ds.variables['latitude'][:]
     assert_that(min(lat), greater_than_or_equal_to(lat_min))
     assert_that(max(lat), less_than_or_equal_to(lat_max))
     lat_1 = self.ds.variables['latitude_1'][:]
     assert_that(min(lat_1), greater_than_or_equal_to(lat_min))
     assert_that(max(lat_1), less_than_or_equal_to(lat_max))
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [variable1, variable2])
Пример #19
0
 def test_GIVEN_multiple_variables_in_ungridded_file_WHEN_subset_THEN_subsetted_correctly(self):
     variable1 = valid_aerosol_cci_variable
     variable2 = valid_aerosol_cci_variable_2
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     arguments = [
         "subset",
         variable1 + "," + variable2 + ":" + filename,
         "x=[%s,%s],y=[%s,%s]" % (lon_min, lon_max, lat_min, lat_max),
         "-o",
         self.OUTPUT_NAME,
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min, False)
     self.check_output_contains_variables(self.UNGRIDDED_OUTPUT_FILENAME, [variable1, variable2])
Пример #20
0
 def test_GIVEN_multiple_variables_in_gridded_file_WHEN_subset_THEN_subsetted_correctly(
         self):
     variable1 = valid_echamham_variable_1
     variable2 = valid_echamham_variable_2
     filename = valid_echamham_filename
     lon_min, lon_max = 0, 10
     lat_min, lat_max = 40, 60
     arguments = [
         'subset',
         variable1 + ',' + variable2 + ':' + escape_colons(filename),
         'x=[%s,%s],y=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max), '-o',
         self.OUTPUT_FILENAME
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min, 'lat',
                                  'lon')
     self.check_output_contains_variables(self.OUTPUT_FILENAME,
                                          [variable1, variable2])
Пример #21
0
 def test_GIVEN_variables_specified_by_wildcard_WHEN_subset_THEN_subsetted_correctly(
         self):
     variable1 = 'surface_albedo???'
     variable2 = 'AOD*'
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     arguments = [
         'subset',
         variable1 + ',' + variable2 + ':' + escape_colons(filename),
         'x=[%s,%s],y=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max), '-o',
         self.OUTPUT_FILENAME
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min)
     self.check_output_contains_variables(self.OUTPUT_FILENAME, [
         'AOD550', 'AOD870', 'surface_albedo550', 'surface_albedo670',
         'surface_albedo870'
     ])
Пример #22
0
    def test_plot_gridded_2d_with_flattened_time(self):
        variable = valid_cis_gridded_output_variable
        filename = valid_cis_gridded_output_filename
        args = [
            'subset', variable + ':' + escape_colons(filename) +
            ":product=NetCDF_Gridded", 't=[2007-06-07T15]', '-o',
            self.OUTPUT_FILENAME
        ]
        args = parse_args(args)
        subset_cmd(args)
        out_name = '3d_out.png'
        args = [
            'plot',
            variable + ':' + self.OUTPUT_FILENAME + ":product=NetCDF_Gridded",
            '-o', out_name
        ]
        main_arguments = parse_args(args)
        plot_cmd(main_arguments)

        os.remove(out_name)
Пример #23
0
 def test_GIVEN_variables_specified_by_wildcard_WHEN_subset_THEN_subsetted_correctly(self):
     variable1 = "surface_albedo???"
     variable2 = "AOD*"
     filename = valid_aerosol_cci_filename
     lon_min, lon_max = -10, 10
     lat_min, lat_max = 40, 60
     arguments = [
         "subset",
         variable1 + "," + variable2 + ":" + filename,
         "x=[%s,%s],y=[%s,%s]" % (lon_min, lon_max, lat_min, lat_max),
         "-o",
         self.OUTPUT_NAME,
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     self.check_latlon_subsetting(lat_max, lat_min, lon_max, lon_min, False)
     self.check_output_contains_variables(
         self.UNGRIDDED_OUTPUT_FILENAME,
         ["AOD550", "AOD870", "surface_albedo550", "surface_albedo670", "surface_albedo870"],
     )
Пример #24
0
    def test_subset_ECHAM_over_0_360_boundary_plots_OK(self):
        var = valid_echamham_variable_1
        filename = valid_echamham_filename
        args = [
            'subset',
            var + ':' + escape_colons(filename) + ":product=NetCDF_Gridded",
            'x=[-10,10]', '-o', self.OUTPUT_FILENAME
        ]
        args = parse_args(args)
        subset_cmd(args)
        out_name = 'subset_echam_boundary.png'
        args = [
            'plot',
            var + ":" + self.OUTPUT_FILENAME + ":product=NetCDF_Gridded",
            '--type', 'contourf', '-o', out_name
        ]
        args = parse_args(args)
        plot_cmd(args)

        os.remove(out_name)
Пример #25
0
 def test_GIVEN_multiple_gridded_variables_on_different_grids_WHEN_subset_THEN_subset_correctly(self):
     variable1 = "v_1"
     variable2 = "rh"
     filename = valid_1d_filename
     lat_min, lat_max = 40, 60
     arguments = [
         "subset",
         variable1 + "," + variable2 + ":" + filename,
         "y=[%s,%s]" % (lat_min, lat_max),
         "-o",
         self.OUTPUT_NAME,
     ]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
     ds = Dataset(self.GRIDDED_OUTPUT_FILENAME)
     lat = ds.variables["latitude"][:]
     assert_that(min(lat), greater_than_or_equal_to(lat_min))
     assert_that(max(lat), less_than_or_equal_to(lat_max))
     lat_1 = ds.variables["latitude_1"][:]
     assert_that(min(lat_1), greater_than_or_equal_to(lat_min))
     assert_that(max(lat_1), less_than_or_equal_to(lat_max))
     self.check_output_contains_variables(self.GRIDDED_OUTPUT_FILENAME, [variable1, variable2])
Пример #26
0
 def do_subset(self, filename, time_min, time_max, variable):
     arguments = ["subset", variable + ":" + filename, "t=[%s,%s]" % (time_min, time_max), "-o", self.OUTPUT_NAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
Пример #27
0
 def do_subset(self, filename, time_min, time_max, variable):
     arguments = ['subset', variable + ':' + filename, 't=[%s,%s]' % (time_min, time_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
Пример #28
0
 def do_subset(self, filename, lat_max, lat_min, lon_max, lon_min, variable):
     arguments = ['subset', variable + ':' + escape_colons(filename),
                  'x=[%s,%s],y=[%s,%s]' % (lon_min, lon_max, lat_min, lat_max), '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
Пример #29
0
 def do_subset(self, filename, variable, alt_bounds='', pres_bounds=''):
     # Join the bounds with a comma if they are both specified
     joint_bounds = ','.join([alt_bounds, pres_bounds]) if alt_bounds and pres_bounds else alt_bounds or pres_bounds
     arguments = ['subset', variable + ':' + escape_colons(filename), joint_bounds, '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)
Пример #30
0
 def do_subset(self, filename, variable, aux_bounds):
     # Join the bounds with a comma if they are both specified
     arguments = ['subset', variable + ':' + escape_colons(filename), aux_bounds, '-o', self.OUTPUT_FILENAME]
     main_arguments = parse_args(arguments)
     subset_cmd(main_arguments)