pankajkarman / bias_correction

python library for bias correction
MIT License
30 stars 8 forks source link

Bias_Correction #1

Open pradhancda opened 4 years ago

pradhancda commented 4 years ago

Sir,

Is it applicable to netcdf ? To do bias correct within era5 (obs) and rcm (model)...... How to merge all netcdf aa rcm data comes separately ? can i run directly in python or any virtual environment is required ?

Please clarify..........

regards, Subhasis

pankajkarman commented 4 years ago

Hi Subhasis, Sorry for the late reply. Yes, this library can be used for netcdfs too except normal mapping which is not yet property implemented for netcdfs but I am working on that and will be available in near future. And there is no need to merge the datasets.

On Sun, 2 Aug, 2020, 6:14 AM pradhancda, notifications@github.com wrote:

Sir,

Is it applicable to netcdf ? To do bias correct within era5 (obs) and rcm (model)...... How to merge all netcdf aa rcm data comes separately ? can i run directly in python or any virtual environment is required ?

Please clarify..........

regards, Subhasis

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pankajkarman/bias_correction/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AID47NBEPY4TZWYJ3TULGOTR6SZHJANCNFSM4PSF4RYQ .

pankajkarman commented 4 years ago

It is recommended to use a separate python environment for new projects to avoid problems in future. There is no python version related problem with this library, but try to use any python3 version to avoid breaking your codes in future.

amolvibhuteIITM commented 8 months ago

Dear sir,

I am appplying gamma_mapping to model data. but it is giving following error

FitError: Optimization converged to parameters that are outside the range allowed by the distribution.

my code is

models = ["MMM"] # Add other models if needed var_names_sec = ["ua"]

for m in models: for var1 in var_names_sec: for ldyr in range(1, 2): ob = xr.open_dataset(var1+'_obs_1960_2012_lead'+str(ldyr)+'.nc') ob.load() obs_data = ob.uwnd.sel(level=(200))

        mo = xr.open_dataset(var1+'_'+m+'_1960_2012_lead'+str(ldyr)+'.nc')
        model_data = mo.ua.sel(plev=(200))

        time = obs_data.time
        lat = obs_data.lat
        lon = obs_data.lon
        model_data = xr.DataArray(model_data, coords=[obs_data.time, lat, lon], dims=['time', 'lat', 'lon'])
        sce_data = model_data
        ds = xr.Dataset({'model_data':obs_data,'obs_data':model_data, 'sce_data':sce_data}) 

        bc = XBiasCorrection(ds['obs_data'], ds['model_data'], ds['sce_data'])
        df3 = bc.correct(method='gamma_mapping')
        df3.to_netcdf(var1+'_'+m+'_1960_2012_lead'+str(ldyr)+'_qmbc.nc')

Please help to resolve the issue.