Skip to content

Station Bias Correction Applied to Structured Grid #153

Description

@msw09090

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!

Activity

  1. btschwertfeger commented on Jan 24, 2025

    @btschwertfeger
    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.

  2. Repository owner locked and limited conversation to collaborators on Jan 24, 2025
  3. converted this issue into a discussion #154 on Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions