Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Station Bias Correction Applied to Structured Grid #153

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

Closed
msw09090 opened this issue Jan 23, 2025 · 1 comment
Closed

Station Bias Correction Applied to Structured Grid #153

msw09090 opened this issue Jan 23, 2025 · 1 comment
Labels
Feature New feature or request

Comments

@msw09090
Copy link

Hello,

Not a problem, but a question/request.

Let's say I have the following;

  1. a time-varying (daily) .csv file of coordinates, an observed z-value, a predicted z-value (let's say 2m-temperature), and...
  2. a structured grid of (lats,lons), all containing predicted z-values.

Using python-cmethods, is it possible to train/build an algorithm from (1; .csv file representing station observations and predictions) then apply it to (2; just representing predictions)?

Thank you!

@msw09090 msw09090 added the Feature New feature or request label Jan 23, 2025
@btschwertfeger
Copy link
Owner

Hello @msw09090, great question.

python-cmethods is designed to be used with NetCDF-based data sets, so you'll need to convert your CSV data into NetCDF. For this you could use pandas and xarray for loading the CSV file, assigning the lats and lons (and time dimension) + saving it to a dataset.

Simplified and not tested example, you may need to perform further steps, depending on the data:

# Python script
import pandas as pd
import numpy as np

scenario = xr.open_dataset("scenario.nc")

# Extract the grid
lats = scenario['latitude']
lons = scenario['longitude']

# Load the CSV data
csv_data = pd.read_csv("temperature_data.csv")

temperature_values = csv_data['temperature'].values # assuming there is a head with this value

# Assume the temperature data is static and spans the grid only once
temperature_grid = temperature_values.reshape(len(lats), len(lons))

# Create an xarray Dataset
ds = xr.Dataset(
    {
        "temperature": (["latitude", "longitude"], temperature_grid)
    },
    coords={
        "latitude": lats,
        "longitude": lons,
    }
)

# Save as NetCDF
ds.to_netcdf("temperature_data.nc")

# ... after that you can use the `ds`/dataset for applying bias correction methods.

The bias adjustment techniques covered in this package are designed to be applied to thee data sets, two of them covering a "historical" time range, the so-called reference period, where one data set is the reference data/observations/reanalysis data and the other is modeled data. These two data sets are then used to bias-adjust a scenario/future/predicted time series.

Using only two datasets is possible, but the results may lack strong statistical significance.

Repository owner locked and limited conversation to collaborators Jan 24, 2025
@btschwertfeger btschwertfeger converted this issue into discussion #154 Jan 24, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants