Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downscaling does not work if all values are zero #254

Open
crdanielbusch opened this issue Aug 28, 2024 · 3 comments · May be fixed by #278
Open

Downscaling does not work if all values are zero #254

crdanielbusch opened this issue Aug 28, 2024 · 3 comments · May be fixed by #278
Labels
bug Something isn't working

Comments

@crdanielbusch
Copy link
Collaborator

Describe the bug

If all values of the basket contents are zero, the downscale_timeseries function does not work.

Expected behavior

The function should fill all empty values with zeros.

Screenshots

Screenshot 2024-08-27 at 15 15 41

System (please complete the following information):

  • OS: macOS
  • Python version 3.10.14
@mikapfl
Copy link
Member

mikapfl commented Aug 28, 2024

Do you have the exact code which was called?

@crdanielbusch
Copy link
Collaborator Author

crdanielbusch commented Aug 28, 2024

sample_1.csv

entity,unit,category,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
CH4,CH4 * gigagram / a,2,,,,,,,,,,,0.0
CO2,CO2 * gigagram / a,2,,,,,,,,,,,0.0
KYOTOGHG (AR5GWP100), CO2 * gigagram / a,2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
N2O,N2O * gigagram / a,2,,,,,,,,,,,0.0

sample_2.csv

entity,unit,category,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
CH4,CH4 * gigagram / a,2,,,,,,,,,,,0.0
CO2,CO2 * gigagram / a,2,,,,,,,,,,,1
KYOTOGHG (AR5GWP100), CO2 * gigagram / a,2,1,1,1,1,1,1,1,1,1,1,1
N2O,N2O * gigagram / a,2,,,,,,,,,,,0.0
import pandas as pd
import primap2 as pm2

df = pd.read_csv("sample.csv")

data_if = pm2.pm2io.convert_wide_dataframe_if(
    df,
    coords_cols={
        "category": "category",
        "entity": "entity",
        "unit": "unit",
    },
    coords_defaults={
        "source": "KNA-GHG-Inventory",
        "provenance": "measured",
        "area": "KNA",
        "scenario": "BUR1",
    },
    coords_terminologies={
        "area": "ISO3",
        "category": "IPCC2006_PRIMAP",
        "scenario": "PRIMAP",
    },
    coords_value_mapping=None,
    filter_remove=None,
    meta_data={
        "references": "https://unfccc.int/documents/633382",
        "rights": "",  # unknown
        "contact": "[email protected]",
        "title": "Saint Kitts and Nevis. Biennial update report (BUR). BUR1",
        "comment": "Read fom pdf by Daniel Busch",
        "institution": "UNFCCC",
    },
    convert_str=True,
    time_format="%Y",
)

data_pm2 = pm2.pm2io.from_interchange_format(data_if)

data_pm2 = data_pm2.pr.downscale_gas_timeseries(
    basket="KYOTOGHG (AR5GWP100)",
    basket_contents=[
        "CO2",
        "CH4",
        "N2O",
    ],
    skipna=True,
    skipna_evaluation_dims=None,
)

data_pm2_downscale_if = data_pm2.pr.to_interchange_format()

Values are filled with sample_2 but not with sample_1.

@mikapfl mikapfl added bug Something isn't working labels Sep 13, 2024
@mikapfl mikapfl added this to the 2024 bugfix sprint milestone Sep 23, 2024
@mikapfl mikapfl self-assigned this Oct 9, 2024
@mikapfl
Copy link
Member

mikapfl commented Oct 9, 2024

Maybe also merge the downscaling function with a newer one developed outside primap2 which also supports external shares.

@mikapfl mikapfl removed their assignment Oct 21, 2024
@JGuetschow JGuetschow linked a pull request Oct 22, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants