コード例 #1
0
    def subsetparams(self, **kwargs):
        """
        Display the subsetting key:value pairs that will be submitted. It generates the dictionary if it does not already exist
        and returns an empty dictionary if subsetting is set to False during ordering.

        Parameters
        ----------
        **kwargs : key-value pairs
            Additional parameters to be passed to the subsetter.
            By default temporal and spatial subset keys are passed.
            Acceptable key values are ['format','projection','projection_parameters','Coverage'].
            At this time (2020-05), only variable ('Coverage') parameters will be automatically formatted.

        See Also
        --------
        order_granules

        Examples
        --------
        >>> reg_a = ipx.Query('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28'])
        >>> reg_a.subsetparams()
        {'time': '2019-02-20T00:00:00,2019-02-28T23:59:59',
        'bbox': '-55.0,68.0,-48.0,71.0'}
        """
        if not hasattr(self, "_subsetparams"):
            self._subsetparams = apifmt.Parameters("subset")

        # temporal subsetting parameters
        if hasattr(self, "_start") and hasattr(self, "_end"):
            kwargs["start"] = self._start
            kwargs["end"] = self._end

        if self._subsetparams == None and not kwargs:
            return {}
        else:
            if self._subsetparams == None:
                self._subsetparams = apifmt.Parameters("subset")
            if self._geom_filepath is not None:
                self._subsetparams.build_params(
                    geom_filepath=self._geom_filepath,
                    extent_type=self.extent_type,
                    spatial_extent=self._spat_extent,
                    **kwargs,
                )
            else:
                self._subsetparams.build_params(
                    extent_type=self.extent_type,
                    spatial_extent=self._spat_extent,
                    **kwargs,
                )

            return self._subsetparams.fmted_keys
コード例 #2
0
def test_CMRparams_no_other_inputs():
    CMRparams = apifmt.Parameters('CMR')
    #TestQuestion: the next statement essentially tests _get_possible_keys as well, so how would I test them independently?
    assert CMRparams.poss_keys == {
        'default': ['short_name', 'version', 'temporal'],
        'spatial': ['bounding_box', 'polygon'],
        'optional': []
    }
    assert CMRparams.fmted_keys == {}
    assert CMRparams._check_valid_keys
    #Note: this test must be done before the next one
    if CMRparams.partype == 'required':
        assert CMRparams.check_req_values() == False
    else:
        assert CMRparams.check_values() == False

    CMRparams.build_params(dataset='ATL06',
                           version='003',
                           start=dt.datetime(2019, 2, 20, 0, 0),
                           end=dt.datetime(2019, 2, 24, 23, 59, 59),
                           extent_type='bounding_box',
                           spatial_extent=[-55, 68, -48, 71])
    obs_fmted_params = CMRparams.fmted_keys
    exp_fmted_params = {
        'short_name': 'ATL06',
        'version': '003',
        'temporal': '2019-02-20T00:00:00Z,2019-02-24T23:59:59Z',
        'bounding_box': '-55,68,-48,71'
    }
    assert obs_fmted_params == exp_fmted_params
コード例 #3
0
def test_CMRparams_no_other_inputs():
    CMRparams = apifmt.Parameters("CMR")
    # TestQuestion: the next statement essentially tests _get_possible_keys as well, so how would I test them independently?
    assert CMRparams.poss_keys == {
        "default": ["short_name", "version"],
        "spatial": ["bounding_box", "polygon"],
        "optional": [
            "temporal", "options[readable_granule_name][pattern]",
            "options[spatial][or]", "readable_granule_name[]"
        ],
    }
    assert CMRparams.fmted_keys == {}
    assert CMRparams._check_valid_keys
    # Note: this test must be done before the next one
    if CMRparams.partype == "required":
        assert CMRparams.check_req_values() == False
    else:
        assert CMRparams.check_values() == False

    CMRparams.build_params(
        dataset="ATL06",
        version="003",
        start=dt.datetime(2019, 2, 20, 0, 0),
        end=dt.datetime(2019, 2, 24, 23, 59, 59),
        extent_type="bounding_box",
        spatial_extent=[-55, 68, -48, 71],
    )
    obs_fmted_params = CMRparams.fmted_keys
    exp_fmted_params = {
        "short_name": "ATL06",
        "version": "003",
        "temporal": "2019-02-20T00:00:00Z,2019-02-24T23:59:59Z",
        "bounding_box": "-55,68,-48,71",
    }
    assert obs_fmted_params == exp_fmted_params
コード例 #4
0
ファイル: query.py プロジェクト: zysisal/icepyx
    def CMRparams(self):
        """
        Display the CMR key:value pairs that will be submitted. It generates the dictionary if it does not already exist.

        Examples
        --------
        >>> reg_a = icepyx.query.Query('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28'])
        >>> reg_a.CMRparams
        {'short_name': 'ATL06',
        'version': '002',
        'temporal': '2019-02-20T00:00:00Z,2019-02-28T23:59:59Z',
        'bounding_box': '-55,68,-48,71'}
        """

        if not hasattr(self, "_CMRparams"):
            self._CMRparams = apifmt.Parameters("CMR")
        # print(self._CMRparams)
        # print(self._CMRparams.fmted_keys)

        # dictionary of optional CMR parameters
        kwargs = {}
        if self._orbit_number:
            kwargs['orbit_number'] = self.orbit_number

        if self._CMRparams.fmted_keys == {}:
            self._CMRparams.build_params(
                dataset=self.dataset,
                version=self._version,
                start=self._start,
                end=self._end,
                extent_type=self.extent_type,
                spatial_extent=self._spat_extent,
            )

        return self._CMRparams.fmted_keys
コード例 #5
0
    def CMRparams(self):
        """
        Display the CMR key:value pairs that will be submitted. It generates the dictionary if it does not already exist.

        Examples
        --------
        >>> reg_a = ipx.Query('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28'])
        >>> reg_a.CMRparams
        {'short_name': 'ATL06',
        'version': '005',
        'temporal': '2019-02-20T00:00:00Z,2019-02-28T23:59:59Z',
        'bounding_box': '-55.0,68.0,-48.0,71.0'}
        """

        if not hasattr(self, "_CMRparams"):
            self._CMRparams = apifmt.Parameters("CMR")
        # print(self._CMRparams)
        # print(self._CMRparams.fmted_keys)

        # dictionary of optional CMR parameters
        kwargs = {}
        # temporal CMR parameters
        if hasattr(self, "_start") and hasattr(self, "_end"):
            kwargs["start"] = self._start
            kwargs["end"] = self._end
        # granule name CMR parameters (orbital or file name)
        # DevGoal: add to file name search to optional queries
        if hasattr(self, "_readable_granule_name"):
            kwargs["options[readable_granule_name][pattern]"] = "true"
            kwargs["options[spatial][or]"] = "true"
            kwargs["readable_granule_name[]"] = self._readable_granule_name

        if self._CMRparams.fmted_keys == {}:
            self._CMRparams.build_params(
                product=self.product,
                version=self._version,
                extent_type=self.extent_type,
                spatial_extent=self._spat_extent,
                **kwargs,
            )

        return self._CMRparams.fmted_keys
コード例 #6
0
    def reqparams(self):
        """
        Display the required key:value pairs that will be submitted. It generates the dictionary if it does not already exist.

        Examples
        --------
        >>> reg_a = ipx.Query('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28'])
        >>> reg_a.reqparams
        {'page_size': 2000}

        >>> reg_a = ipx.Query('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28']) # doctest: +SKIP
        >>> reg_a.earthdata_login(user_id,user_email) # doctest: +SKIP
        Earthdata Login password:  ········
        >>> reg_a.order_granules() # doctest: +SKIP
        >>> reg_a.reqparams # doctest: +SKIP
        {'page_size': 2000, 'page_num': 1, 'request_mode': 'async', 'include_meta': 'Y', 'client_string': 'icepyx'}
        """

        if not hasattr(self, "_reqparams"):
            self._reqparams = apifmt.Parameters("required", reqtype="search")
            self._reqparams.build_params()

        return self._reqparams.fmted_keys
コード例 #7
0
    def reqparams(self):
        """
        Display the required key:value pairs that will be submitted. It generates the dictionary if it does not already exist.
        
        Examples
        --------
        >>> reg_a = icepyx.icesat2data.Icesat2Data('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28'])
        >>> reg_a.reqparams
        {'page_size': 10, 'page_num': 1}

        >>> reg_a = icepyx.icesat2data.Icesat2Data('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28'])
        >>> reg_a.earthdata_login(user_id,user_email)
        Earthdata Login password:  ········
        >>> reg_a.order_granules()
        >>> reg_a.reqparams
        {'page_size': 10, 'page_num': 1, 'request_mode': 'async', 'include_meta': 'Y'}
        """

        if not hasattr(self, '_reqparams'):
            self._reqparams = apifmt.Parameters('required', reqtype='search')
            self._reqparams.build_params()

        return self._reqparams.fmted_keys
コード例 #8
0
    def CMRparams(self):
        """
        Display the CMR key:value pairs that will be submitted. It generates the dictionary if it does not already exist.
        
        Examples
        --------
        >>> reg_a = icepyx.icesat2data.Icesat2Data('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28'])
        >>> reg_a.CMRparams
        {'short_name': 'ATL06',
        'version': '002',
        'temporal': '2019-02-20T00:00:00Z,2019-02-28T23:59:59Z',
        'bounding_box': '-55,68,-48,71'}
        """

        if not hasattr(self, '_CMRparams'):
            self._CMRparams = apifmt.Parameters('CMR')
        # print(self._CMRparams)
        # print(self._CMRparams.fmted_keys)

        if self._CMRparams.fmted_keys == {}:
            self._CMRparams.build_params(dataset=self.dataset, version=self._version,\
                    start=self._start, end=self._end, extent_type=self.extent_type, spatial_extent=self._spat_extent)

        return self._CMRparams.fmted_keys