pankajkarman / bias_correction

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

An error related to numpy array in the module #16

Open Karim-Soliman29 opened 2 years ago

Karim-Soliman29 commented 2 years ago

Hallo Mr. Pankajkarman,

First of all, I would like to thank you for developing this module. This module would help me alot. However, I faced an error and I tried to debug it but I couldn't. Here is the error:

Traceback (most recent call last): File "Z:\data\Projekte\000897-21.NBI.ClimateServiceInfrastructure\4_Data\NileDST-FAO\Biascorrection\Test\416_new_2\bias correction new.py", line 65, in corrected=bc.correct("gamma_mapping",lower_limit=5) File "C:\Users\KarimSoliman\AppData\Roaming\Python\Python37\site-packages\bias_correction-0.4-py3.7.egg\bias_correction.py", line 206, in correct cdf_threshold=cdf_threshold, File "C:\Users\KarimSoliman\AppData\Roaming\Python\Python37\site-packages\bias_correction-0.4-py3.7.egg\bias_correction.py", line 132, in gamma_correction correction = pd.Series(correction, index=sce_data.index) AttributeError: 'numpy.ndarray' object has no attribute 'index'

Would you like recommend me an approach to debug this error?

Thanks in advance Best regards, Karim Soliman

winash12 commented 1 year ago

I am getting the same error

File "redfit.py", line 350, in <module> main() File "redfit.py", line 59, in main corrected = bc.correct(method='gamma_mapping') File "/usr/local/lib/python3.8/dist-packages/bias_correction-0.4-py3.8.egg/bias_correction.py", line 224, in correct AttributeError: 'numpy.ndarray' object has no attribute 'index'

mgironamata commented 1 year ago

I have encountered a similar issue, @Karim-Soliman29 and @winash12

If you go to the bias_correction.py file and do the following changes, it should work:

1) Towards the end of the correct function in the BiasCorrection class, comment out the following line: # self.corrected = pd.Series(corrected, index=self.sce_data.index) and instead, add the below: self.corrected = corrected just before the return statement. It should look like this: # self.corrected = pd.Series(corrected, index=self.sce_data.index) self.corrected = corrected return self.corrected

2) In the gamma_correction and normal_correction functions, chech that the following line, which should be the last line before the return statement in each function, is commented out (these were already commented out in the version I downloaded): # correction = pd.Series(correction, index=sce_data.index)

I trust this helps, and hope it makes sense to @pankajkarman?

winash12 commented 1 year ago

@mgironamata Why dont you make this into a pull request and merge it ?

mgironamata commented 1 year ago

@winash12 thanks for the suggestion. I have made a pull request.

winash12 commented 1 year ago

@mgironamata Not sure in this case but @pankajkarman may demand a test case that shows the problem goes away.