def demonstration(conf='default.conf'): ''' Need to develop a new demo ''' from eoldas_Lib import eoldas_setup from os import getcwd from eoldas_ParamStorage import ParamStorage options = ParamStorage() options.here = getcwd() options.logdir = 'logs' options.logfile = "logfile.log" options.datadir = ['.','~/.eoldas'] #self = eoldas_setup('default.conf',options) #return self return True
def demonstration(): from eoldas_State import State from eoldas_ParamStorage import ParamStorage import numpy as np # a basic set up for State, setting names & bounds etc options = ParamStorage() options.logfile = 'test/data_type/logs/log.dat' options.names = \ 'gamma xlai xhc rpl xkab scen xkw xkm xleafn xs1 xs2 xs3 xs4 lad'.split() options.bounds = [[0.01,None],\ [0.01,0.99],\ [0.01,10.0],\ [0.001,0.10],\ [0.1,0.99],\ [0.0,1.0],\ [0.01,0.99],\ [0.3,0.9],\ [0.9,2.5],\ [0.0, 4.],\ [0.0, 5.],\ [None, None],\ [None, None],\ [None, None]] options.default = -1.0*np.ones(len(options.names)) options.location = 'time'.split() options.control = 'mask vza vaa sza saa'.split() options.datadir = ['.','test/data_type'] name = "eoldas_data_type test 0" options.limits = [[170,365,1]] self = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile) self.tester() # Now we set some state data this = ParamStorage() # how many state vector elements should there be? n_states = len(self.Name.state) self.state = np.ones([100,n_states]) self.Data.sd = np.ones([1,n_states]) self.Name.sd = self.Name.state print '******************' print (self.Data.sd,self.Name.sd) this.data = ParamStorage() this.name = ParamStorage() this.data.state = self.state *2 controls = self.Name.control n_controls = len(controls) this.data.control = np.ones([100,n_controls]) this.data.location = np.ones([100,n_controls]) # we can load x_state from a ParamStorage self.state = this # now we should see the control data etc. self.tester() # change a dataset name to see if that works: # should load everything as numpy arrays self.Name.control = np.array(['vza','sza']) # change a dataset to see if that works .. deliberately load a bad one self.Data.control = 0 # now try a direct state data load self.state = np.zeros([100,100])+5. # which will load into self.Data.state self['state'] = np.zeros([100,100])+6. #now try accessing it: print self.state # change the control info self.Name.control = np.array(['vza']) print self.Name.control # reset it self.state = self.state * 2 print self.state # now try reading a file into state self.state = 'test/data_type/input/test.brf' print '========' print 'data from a BRDF file' self.tester() print '========' # written as a pickle self.write('test/data_type/output/test.pickle',None,fmt='pickle') self.logger.info("...DONE...") name = "eoldas_data_type test 1" del self self1 = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile,grid=True) # read from pickle self1.state = 'test/data_type/output/test.pickle' print '========' print 'data from a pickle file' self1.tester() print '========' # try to load an npx file del self1 options.location = 'time row col'.split() options.limits = [[170,365,1],[0,500,1],[200,200,1]] self2 = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile) self2.state = 'test/data_type/input/interpolated_data.npz' print '========' print 'data from a npz file' self2.tester() print '========' # write as BRDF-UCL self2.write('test/data_type/output/test.brf',None,fmt='BRDF-UCL') del self2 self3 = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile) # then test the reader self3.state = 0. self3.state = 'test/data_type/output/test.brf' print '========' print 'data from a BRDF-UCL file' print '========' self3.tester() print '========' # then write as a PARAMETERS file self3.write('test/data_type/output/test.param',None,fmt='PARAMETERS') del self3 options.location = 'time row col'.split() options.limits = [[170,365,1],[0,500,1],[200,200,1]] options.control = np.array(['mask','vza','vaa','sza','saa']) self4 = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile) # then test the reader self4.state = 0. self4.state = 'test/data_type/output/test.param' print '========' print 'data from a PARAMETERS file' print '========' self4.tester() print '========'
def demonstration(): from eoldas_State import State from eoldas_ParamStorage import ParamStorage import numpy as np # a basic set up for State, setting names & bounds etc options = ParamStorage() options.logfile = 'test/data_type/logs/log.dat' options.names = \ 'gamma xlai xhc rpl xkab scen xkw xkm xleafn xs1 xs2 xs3 xs4 lad'.split() options.bounds = [[0.01,None],\ [0.01,0.99],\ [0.01,10.0],\ [0.001,0.10],\ [0.1,0.99],\ [0.0,1.0],\ [0.01,0.99],\ [0.3,0.9],\ [0.9,2.5],\ [0.0, 4.],\ [0.0, 5.],\ [None, None],\ [None, None],\ [None, None]] options.default = -1.0 * np.ones(len(options.names)) options.location = 'time'.split() options.control = 'mask vza vaa sza saa'.split() options.datadir = ['.', 'test/data_type'] name = "eoldas_data_type test 0" options.limits = [[170, 365, 1]] self = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile) self.tester() # Now we set some state data this = ParamStorage() # how many state vector elements should there be? n_states = len(self.Name.state) self.state = np.ones([100, n_states]) self.Data.sd = np.ones([1, n_states]) self.Name.sd = self.Name.state print '******************' print(self.Data.sd, self.Name.sd) this.data = ParamStorage() this.name = ParamStorage() this.data.state = self.state * 2 controls = self.Name.control n_controls = len(controls) this.data.control = np.ones([100, n_controls]) this.data.location = np.ones([100, n_controls]) # we can load x_state from a ParamStorage self.state = this # now we should see the control data etc. self.tester() # change a dataset name to see if that works: # should load everything as numpy arrays self.Name.control = np.array(['vza', 'sza']) # change a dataset to see if that works .. deliberately load a bad one self.Data.control = 0 # now try a direct state data load self.state = np.zeros([100, 100]) + 5. # which will load into self.Data.state self['state'] = np.zeros([100, 100]) + 6. #now try accessing it: print self.state # change the control info self.Name.control = np.array(['vza']) print self.Name.control # reset it self.state = self.state * 2 print self.state # now try reading a file into state self.state = 'test/data_type/input/test.brf' print '========' print 'data from a BRDF file' self.tester() print '========' # written as a pickle self.write('test/data_type/output/test.pickle', None, fmt='pickle') self.logger.info("...DONE...") name = "eoldas_data_type test 1" del self self1 = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile,grid=True) # read from pickle self1.state = 'test/data_type/output/test.pickle' print '========' print 'data from a pickle file' self1.tester() print '========' # try to load an npx file del self1 options.location = 'time row col'.split() options.limits = [[170, 365, 1], [0, 500, 1], [200, 200, 1]] self2 = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile) self2.state = 'test/data_type/input/interpolated_data.npz' print '========' print 'data from a npz file' self2.tester() print '========' # write as BRDF-UCL self2.write('test/data_type/output/test.brf', None, fmt='BRDF-UCL') del self2 self3 = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile) # then test the reader self3.state = 0. self3.state = 'test/data_type/output/test.brf' print '========' print 'data from a BRDF-UCL file' print '========' self3.tester() print '========' # then write as a PARAMETERS file self3.write('test/data_type/output/test.param', None, fmt='PARAMETERS') del self3 options.location = 'time row col'.split() options.limits = [[170, 365, 1], [0, 500, 1], [200, 200, 1]] options.control = np.array(['mask', 'vza', 'vaa', 'sza', 'saa']) self4 = State(options,datatype='y',name=name,datadir=\ options.datadir,env=None,logfile=options.logfile) # then test the reader self4.state = 0. self4.state = 'test/data_type/output/test.param' print '========' print 'data from a PARAMETERS file' print '========' self4.tester() print '========'