Example #1
0
    def __init__(
        self,
        dataset=None,
        spatial_extent=None,
        date_range=None,
        start_time=None,
        end_time=None,
        version=None,
        cycles=None,
        tracks=None,
        files=None,
    ):

        # warnings.filterwarnings("always")
        # warnings.warn("Please note: as of 2020-05-05, a major reorganization of the core icepyx.query code may result in errors produced by now depricated functions. Please see our documentation pages or example notebooks for updates.")

        if (
            (dataset is None or spatial_extent is None)
            and (date_range is None or cycles is None or tracks is None)
            and files is None
        ):
            raise ValueError(
                "Please provide the required inputs. Use help([function]) to view the function's documentation"
            )

        if files is not None:
            self._source = "files"
            # self.file_vars = Variables(self._source)
        else:
            self._source = "order"
            # self.order_vars = Variables(self._source)
        # self.variables = Variables(self._source)

        self._dset = is2ref._validate_dataset(dataset)

        self.extent_type, self._spat_extent, self._geom_filepath = val.spatial(
            spatial_extent
        )

        if date_range:
            self._start, self._end = val.temporal(date_range, start_time, end_time)

        self._version = val.dset_version(self.latest_version(), version)

        # build list of available CMR parameters if reducing by cycle or RGT
        # or a list of explicitly named files (full or partial names)
        # DevGoal: add file name search to optional queries
        if cycles or tracks:
            # get lists of available ICESat-2 cycles and tracks
            self._cycles = val.cycles(cycles)
            self._tracks = val.tracks(tracks)
            # create list of CMR parameters for granule name
            self._readable_granule_name = apifmt._fmt_readable_granules(
                self._dset, cycles=self.cycles, tracks=self.tracks
            )
Example #2
0
    def __init__(
        self, spatial_extent=None, date_range=None, start_time=None, end_time=None
    ):
        # validate & init spatial extent
        self.extent_type, self._spat_extent, self._geom_filepath = val.spatial(
            spatial_extent
        )

        # valiidate and init temporal constraints
        if date_range:
            self._start, self._end = val.temporal(date_range, start_time, end_time)
Example #3
0
def test_intlist_latlon_coords():
    out = val.spatial([-55, 68, -55, 71, -48, 71, -48, 68, -55, 68])
    obs = [
        out[0], out[1].exterior.coords.xy[0].tolist(),
        out[1].exterior.coords.xy[1].tolist(), out[2]
    ]
    expected = [
        'polygon', [-55.0, -55.0, -48.0, -48.0, -55.0],
        [68.0, 71.0, 71.0, 68.0, 68.0], None
    ]
    for i in range(len(expected)):
        assert obs[i] == expected[i]
Example #4
0
def test_tuple_latlon_pairs():
    out = val.spatial([(-55, 68), (-55, 71), (-48, 71), (-48, 68), (-55, 68)])
    obs = [
        out[0],
        out[1].exterior.coords.xy[0].tolist(),
        out[1].exterior.coords.xy[1].tolist(),
        out[2],
    ]
    expected = [
        "polygon",
        [-55.0, -55.0, -48.0, -48.0, -55.0],
        [68.0, 71.0, 71.0, 68.0, 68.0],
        None,
    ]
    for i in range(len(expected)):
        assert obs[i] == expected[i]
Example #5
0
def test_floatlist_latlon_coords():
    out = val.spatial(
        [-55.0, 68.7, -55.0, 71, -48, 71, -48, 68.7, -55.0, 68.7])
    obs = [
        out[0],
        out[1].exterior.coords.xy[0].tolist(),
        out[1].exterior.coords.xy[1].tolist(),
        out[2],
    ]
    expected = [
        "polygon",
        [-55.0, -55.0, -48.0, -48.0, -55.0],
        [68.7, 71.0, 71.0, 68.7, 68.7],
        None,
    ]
    for i in range(len(expected)):
        assert obs[i] == expected[i]
Example #6
0
def test_list_latlon_pairs():
    out = val.spatial([[-55, 68], [-55, 71], [-48, 71], [-48, 68], [-55, 68]])
    obs = [
        out[0],
        out[1].exterior.coords.xy[0].tolist(),
        out[1].exterior.coords.xy[1].tolist(),
        out[2],
    ]
    # expected = ['polygon', [-55.0, 68.0, -55.0, 71.0, -48.0, 71.0, -48.0, 68.0, -55.0, 68.0], None]
    # expected = ['polygon', [[-55.0, 68.0], [-55.0, 71.0], [-48.0, 71.0], [-48.0, 68.0], [-55.0, 68.0]], None]
    expected = [
        "polygon",
        [-55.0, -55.0, -48.0, -48.0, -55.0],
        [68.0, 71.0, 71.0, 68.0, 68.0],
        None,
    ]
    for i in range(len(expected)):
        assert obs[i] == expected[i]
Example #7
0
    def __init__(
        self,
        dataset=None,
        spatial_extent=None,
        date_range=None,
        start_time=None,
        end_time=None,
        version=None,
        files=None,
    ):

        warnings.filterwarnings("always")
        warnings.warn(
            "Please note: as of 2020-05-05, a major reorganization of the core icepyx.icesat2data code may result in errors produced by now depricated functions. Please see our documentation pages or example notebooks for updates."
        )

        if (dataset is None or spatial_extent is None
                or date_range is None) and files is None:
            raise ValueError(
                "Please provide the required inputs. Use help([function]) to view the function's documentation"
            )

        if files is not None:
            self._source = 'files'
            # self.file_vars = Variables(self._source)
        else:
            self._source = 'order'
            # self.order_vars = Variables(self._source)
        # self.variables = Variables(self._source)

        self._dset = is2ref._validate_dataset(dataset)

        self.extent_type, self._spat_extent, self._geom_filepath = val.spatial(
            spatial_extent)

        self._start, self._end = val.temporal(date_range, start_time, end_time)

        self._version = val.dset_version(self.latest_version(), version)
Example #8
0
def test_floatlist_bbox():
    obs = val.spatial([-64.2, 66.2, -55.5, 72.5])
    expected = ["bounding_box", [-64.2, 66.2, -55.5, 72.5], None]
    for i in range(len(expected)):
        assert obs[i] == expected[i]
Example #9
0
def test_intlist_bbox():
    obs = val.spatial([-64, 66, -55, 72])
    expected = ["bounding_box", [-64, 66, -55, 72], None]
    for i in range(len(expected)):
        assert obs[i] == expected[i]
Example #10
0
def test_poly_spat_file_input():
    ermsg = "Check that the path and filename of your geometry file are correct"
    with pytest.raises(AssertionError, match=ermsg):
        val.spatial("file_path/name/invalid_type.txt")
Example #11
0
def test_spat_input_type():
    ermsg = "Your spatial extent does not meet minimum input criteria"
    with pytest.raises(ValueError, match=ermsg):
        val.spatial([-64, 66, (-55, 72), 72])
def test_numpyfloatarray_bbox():
    obs = val.spatial(np.array([-64.2, 66.2, -55.5, 72.5]))
    expected = ["bounding_box", [-64.2, 66.2, -55.5, 72.5], None]
    for i in range(len(expected)):
        assert obs[i] == expected[i]
Example #13
0
    def __init__(
        self,
        dataset=None,
        spatial_extent=None,
        date_range=None,
        start_time=None,
        end_time=None,
        version=None,
        cycles=None,
        tracks=None,
        orbit_number=None,
        files=None,
    ):

        # warnings.filterwarnings("always")
        # warnings.warn("Please note: as of 2020-05-05, a major reorganization of the core icepyx.query code may result in errors produced by now depricated functions. Please see our documentation pages or example notebooks for updates.")

        if (dataset is None or spatial_extent is None
                or date_range is None) and files is None:
            raise ValueError(
                "Please provide the required inputs. Use help([function]) to view the function's documentation"
            )

        if files is not None:
            self._source = "files"
            # self.file_vars = Variables(self._source)
        else:
            self._source = "order"
            # self.order_vars = Variables(self._source)
        # self.variables = Variables(self._source)

        self._dset = is2ref._validate_dataset(dataset)

        self.extent_type, self._spat_extent, self._geom_filepath = val.spatial(
            spatial_extent)

        self._start, self._end = val.temporal(date_range, start_time, end_time)

        self._version = val.dset_version(self.latest_version(), version)

        # list of CMR orbit number parameters
        self._orbit_number = []
        # get list of available ICESat-2 cycles and tracks
        all_cycles, all_tracks = self.avail_granules(ids=False,
                                                     cycles=True,
                                                     tracks=True)
        self._cycles = val.cycles(all_cycles, cycles)
        self._tracks = val.tracks(all_tracks, tracks)
        # build list of available CMR orbit number if reducing by cycle or RGT
        if cycles or tracks:
            # for each available cycle of interest
            for c in self.cycles:
                # for each available track of interest
                for t in self.tracks:
                    self._orbit_number.append(
                        int(t) + (int(c) - 1) * 1387 + 201)
            # update the CMR parameters for orbit_number
            self.CMRparams['orbit_number'] = self.orbit_number
            # update required parameters (number of pages)
            self._reqparams.build_params()
            # update the list of available granules
            self.granules.get_avail(self.CMRparams, self.reqparams)