Ejemplo n.º 1
0
    def test_add_gridded_geolocation_variables(self):
        ds = xr.Dataset()
        TemplateUtil.add_gridded_geolocation_variables(ds, 9, 11)

        lat = ds.variables["lat"]
        self.assertEqual((11, ), lat.shape)
        self.assertTrue(np.isnan(lat.data[5]))
        self.assertTrue(np.isnan(lat.attrs['_FillValue']))
        self.assertEqual("latitude", lat.attrs["standard_name"])
        self.assertEqual("latitude", lat.attrs["long_name"])
        self.assertEqual("degrees_north", lat.attrs["units"])
        self.assertEqual("lat_bnds", lat.attrs["bounds"])

        lat_bnds = ds.variables["lat_bnds"]
        self.assertEqual((11, 2), lat_bnds.shape)
        self.assertTrue(np.isnan(lat_bnds.data[6, 0]))
        self.assertTrue(np.isnan(lat_bnds.attrs['_FillValue']))
        self.assertEqual("latitude cell boundaries",
                         lat_bnds.attrs["long_name"])
        self.assertEqual("degrees_north", lat_bnds.attrs["units"])

        lon = ds.variables["lon"]
        self.assertEqual((9, ), lon.shape)
        self.assertTrue(np.isnan(lon.data[6]))
        self.assertTrue(np.isnan(lon.attrs['_FillValue']))
        self.assertEqual("longitude", lon.attrs["standard_name"])
        self.assertEqual("longitude", lon.attrs["long_name"])
        self.assertEqual("degrees_east", lon.attrs["units"])
        self.assertEqual("lon_bnds", lon.attrs["bounds"])

        lon_bnds = ds.variables["lon_bnds"]
        self.assertEqual((9, 2), lon_bnds.shape)
        self.assertTrue(np.isnan(lon_bnds.data[7, 1]))
        self.assertTrue(np.isnan(lon_bnds.attrs['_FillValue']))
        self.assertEqual("longitude cell boundaries",
                         lon_bnds.attrs["long_name"])
        self.assertEqual("degrees_east", lon_bnds.attrs["units"])
Ejemplo n.º 2
0
    def add_variables(dataset, width, height):
        WriterUtils.add_gridded_global_attributes(dataset)

        tu.add_gridded_geolocation_variables(dataset, width, height)
        tu.add_quality_flags(dataset, width, height)

        dataset["time_ranges_ascend"] = UTH._create_time_ranges_variable(
            height, width,
            "Minimum and maximum seconds of day pixel contribution time, ascending nodes"
        )
        dataset["time_ranges_descend"] = UTH._create_time_ranges_variable(
            height, width,
            "Minimum and maximum seconds of day pixel contribution time, descending nodes"
        )

        dataset[
            "observation_count_ascend"] = UTH._create_observation_counts_variable(
                height, width,
                "Number of UTH/brightness temperature observations in a grid box for ascending passes"
            )
        dataset[
            "observation_count_descend"] = UTH._create_observation_counts_variable(
                height, width,
                "Number of UTH/brightness temperature observations in a grid box for descending passes"
            )

        dataset["overpass_count_ascend"] = UTH._create_overpass_counts_variable(
            height, width,
            "Number of satellite overpasses in a grid box for ascending passes"
        )
        dataset["overpass_count_descend"] = UTH._create_overpass_counts_variable(
            height, width,
            "Number of satellite overpasses in a grid box for descending passes"
        )

        dataset["uth_ascend"] = UTH._create_uth_variable(
            width,
            height,
            description=
            "Monthly average of all UTH retrievals in a grid box for ascending passes (calculated from daily averages)",
        )
        dataset["uth_descend"] = UTH._create_uth_variable(
            width,
            height,
            description=
            "Monthly average of all UTH retrievals in a grid box for descending passes (calculated from daily averages)"
        )

        dataset["u_independent_uth_ascend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of UTH due to independent effects for ascending passes",
            coordinates="lon lat")
        dataset["u_independent_uth_descend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of UTH due to independent effects for descending passes",
            coordinates="lon lat")
        dataset["u_structured_uth_ascend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of UTH due to structured effects for ascending passes",
            coordinates="lon lat")
        dataset["u_structured_uth_descend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of UTH due to structured effects for descending passes",
            coordinates="lon lat")
        dataset["u_common_uth_ascend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of UTH due to common effects for ascending passes",
            coordinates="lon lat")
        dataset["u_common_uth_descend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of UTH due to common effects for descending passes",
            coordinates="lon lat")

        dataset["uth_inhomogeneity_ascend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Standard deviation of all daily UTH averages which were used to calculate the monthly UTH average in a grid box for ascending passes",
            coordinates="lon lat")
        dataset["uth_inhomogeneity_descend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Standard deviation of all daily UTH averages which were used to calculate the monthly UTH average in a grid box for descending passes",
            coordinates="lon lat")

        dataset["BT_ascend"] = UTH._create_bt_variable(
            width,
            height,
            description=
            "Monthly average of all brightness temperatures which were used to retrieve UTH in a grid box for ascending passes (calculated from daily averages)"
        )
        dataset["BT_descend"] = UTH._create_bt_variable(
            width,
            height,
            description=
            "Monthly average of all brightness temperatures which were used to retrieve UTH in a grid box for descending passes (calculated from daily averages)"
        )

        dataset["u_independent_BT_ascend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of brightness temperature due to independent effects for ascending passes",
            coordinates="lon lat",
            units="K")
        dataset["u_independent_BT_descend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of brightness temperature due to independent effects for descending passes",
            coordinates="lon lat",
            units="K")

        dataset["u_structured_BT_ascend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of brightness temperature due to structured effects for ascending passes",
            coordinates="lon lat",
            units="K")
        dataset["u_structured_BT_descend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of brightness temperature due to structured effects for descending passes",
            coordinates="lon lat",
            units="K")

        dataset["u_common_BT_ascend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of brightness temperature due to common effects for ascending passes",
            coordinates="lon lat",
            units="K")
        dataset["u_common_BT_descend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Uncertainty of brightness temperature due to common effects for descending passes",
            coordinates="lon lat",
            units="K")

        dataset["BT_inhomogeneity_ascend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Standard deviation of all daily brightness temperature averages which were used to calculate the monthly brightness temperature average for ascending passes",
            coordinates="lon lat",
            units="K")
        dataset["BT_inhomogeneity_descend"] = tu.create_CDR_uncertainty(
            width,
            height,
            "Standard deviation of all daily brightness temperature averages which were used to calculate the monthly brightness temperature average for descending passes",
            coordinates="lon lat",
            units="K")

        dataset[
            "observation_count_all_ascend"] = UTH._create_observation_counts_variable(
                height, width,
                "Number of all observations in a grid box for ascending passes - no filtering done"
            )
        dataset[
            "observation_count_all_descend"] = UTH._create_observation_counts_variable(
                height, width,
                "Number of all observations in a grid box for descending passes - no filtering done"
            )