Closed monbiola closed 1 year ago
Hi @monbiola, thank you for your message. The getdata function is implemented as a base function for all algorithms within spotpy. You can use it with:
results = sampler.getdata()
Just as a sidenote: Pandas gives you the possibility to load only parts of a file. E.g. if you are only interested to load the Objective function column from your file, you could use:
import pandas as pd results = pd.read_csv(PATH_DATA+'.csv', usecols = ['like1'], low_memory = True)
This might prevent a memory error.
Hi @thouska,
thank you for your answer. I had seen in the code the getdata function is implemented as a base function for all algorithms, but for Fast algorithm it doesn't seem to work. I reproduce the bug by executing the code in example in the pkg (tutorial_fast_hymod.py). I have the 1.6.1 Spotpy version
import spotpy from spotpy.examples.spot_setup_hymod_python import spot_setup
if name == "main": parallel ='seq'
spot_setup = spot_setup()
#Select number of maximum repetitions
rep = 1345
#Start a sensitivity analysis
sampler = spotpy.algorithms.fast(spot_setup, dbname='FAST_hymod', dbformat='csv')
sampler.sample(rep)
# Load the results gained with the fast sampler, stored in FAST_hymod.csv
results = spotpy.analyser.load_csv_results('FAST_hymod')
# Example plot to show the sensitivity index of each parameter
spotpy.analyser.plot_fast_sensitivity(results, number_of_sensitiv_pars=3)
# Example to get the sensitivity index of each parameter
SI = spotpy.analyser.get_sensitivity_of_fast(results)
## Add for test
results_sampler = sampler.get_data()
spotpy.analyser.plot_fast_sensitivit(results_sampler,number_of_sensitiv_pars=3)
The error from this code
results_sampler = sampler.get_data() AttributeError: 'fast' object has no attribute 'get_data
Do you also have this error?
thanks for the tip to prevent memory error, I will try that too.
Hi @monbiola, I think, if you change the line
results_sampler = sampler.get_data()
to
results_sampler = sampler.getdata()
it should work
Yes it works like that :) I based on the doc https://spotpy.readthedocs.io/en/latest/Sensitivity_analysis_with_FAST/ where it says get_data instead of getdata
Thank you !
Ah, perfect thank you. I changed the documentation accordingly now.
Hi,
I am trying to make an Sensitivity analysis of a python model with FAST method.
My code is
... sampler = spotpy.algorithms.fast(spot_setup, dbname=PATH_DATA, dbformat='csv', parallel='mpi') sampler.sample(rep) results = sampler.get_data()
[I want to directly loaded results from the sampler instead of loading the results from the csv database because with this last method I have a memory error (file ~ 3GB).]
But I have the error
results = sampler.get_data() AttributeError: 'fast' object has no attribute 'get_data'
Is it a bug on my side or get_data method isn't implemented for fast Class ?
Thanks