• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ghiggi / gpm_api / 8237698134

11 Mar 2024 06:10PM UTC coverage: 81.754%. First build
8237698134

Pull #42

github

ghiggi
Remove test plot data
Pull Request #42: Rename package import and xarray accessor from `gpm_api` to `gpm`

388 of 453 new or added lines in 79 files covered. (85.65%)

7998 of 9783 relevant lines covered (81.75%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.94
/gpm/dataset/decoding/routines.py
1
# -----------------------------------------------------------------------------.
2
# MIT License
3

4
# Copyright (c) 2024 GPM-API developers
5
#
6
# This file is part of GPM-API.
7

8
# Permission is hereby granted, free of charge, to any person obtaining a copy
9
# of this software and associated documentation files (the "Software"), to deal
10
# in the Software without restriction, including without limitation the rights
11
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
# copies of the Software, and to permit persons to whom the Software is
13
# furnished to do so, subject to the following conditions:
14
#
15
# The above copyright notice and this permission notice shall be included in all
16
# copies or substantial portions of the Software.
17
#
18
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
# SOFTWARE.
25

26
# -----------------------------------------------------------------------------.
27
"""This module contains functions to apply the products decoding routines."""
1✔
28
import importlib
1✔
29

30
from gpm.io.products import available_products
1✔
31

32
# TODO:
33
# - implement accessor ds.gpm.decode_variable(variable)
34
# - use gpm_api_product attribute to recognize where decode_<variable> function is
35
# - run decoding only if gpm_api_decoded not present (or "no"). If "yes", raise error (already decoded)
36

37

38
def _get_decoding_function(module_name):
1✔
39
    """Retrieve the decode_product function from a specific module."""
40
    module = importlib.import_module(module_name)
×
41
    decode_function = getattr(module, "decode_product", None)
×
42

43
    if decode_function is None or not callable(decode_function):
×
44
        raise ValueError("decode_product function not found in the {module_name} module.")
×
45

46
    return decode_function
×
47

48

49
def decode_variables(ds, product):
1✔
50
    """Decode the variables of a given GPM product."""
51
    # Decode variables of 2A-<RADAR> products
52
    if product in available_products(product_categories="RADAR", product_levels="2A"):
1✔
NEW
53
        ds = _get_decoding_function("gpm.dataset.decoding.decode_2a_radar")(ds)
×
54

55
    # Decode variables of 2A-<PMW> products
56
    if product in available_products(product_categories="PMW", product_levels="2A"):
1✔
NEW
57
        ds = _get_decoding_function("gpm.dataset.decoding.decode_2a_pmw")(ds)
×
58

59
    # Decode variables of 2A-<PMW> products
60
    if product in available_products(product_categories="PMW", product_levels="1C"):
1✔
NEW
61
        ds = _get_decoding_function("gpm.dataset.decoding.decode_1c_pmw")(ds)
×
62

63
    # if ds.attrs.get("TotalQualityCode"):
64
    #     TotalQualityCode = ds.attrs.get("TotalQualityCode")
65
    #     ds["TotalQualityCode"] = xr.DataArray(
66
    #         np.repeat(TotalQualityCode, ds.sizes["along_track"]), dims=["along_track"]
67
    #     )
68

69
    return ds
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc