You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Station Bias Correction Applied to Structured Grid #153
a time-varying (daily) .csv file of coordinates, an observed z-value, a predicted z-value (let's say 2m-temperature), and...
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)?
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 scriptimportpandasaspdimportnumpyasnpscenario=xr.open_dataset("scenario.nc")
# Extract the gridlats=scenario['latitude']
lons=scenario['longitude']
# Load the CSV datacsv_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 oncetemperature_grid=temperature_values.reshape(len(lats), len(lons))
# Create an xarray Datasetds=xr.Dataset(
{
"temperature": (["latitude", "longitude"], temperature_grid)
},
coords={
"latitude": lats,
"longitude": lons,
}
)
# Save as NetCDFds.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 on Jan 24, 2025
Activity
btschwertfeger commentedon Jan 24, 2025
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:
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.