예제 #1
0
def calc_inv(f_red, f_nir, saa_true, azim, lad, conf_file, f_result):
        f = open(f_red, 'r')
        tmp_str = f.read()
        f.close()
        list1 = tmp_str.split('\n')
        f = open(f_nir, 'r')
        tmp_str = f.read()
        f.close()
        list2 = tmp_str.split('\n')

        red = np.zeros(len(list1)-1)
        nir = np.zeros(len(list1)-1)
        sza = np.zeros(len(list1)-1)
        saa = np.zeros(len(list1)-1)
        vza = np.zeros(len(list1)-1)
        vaa = np.zeros(len(list1)-1)

        for i in range( 1, len(list1)-1 ):
            red[i] = list1[i].split()[3]
            nir[i] = list2[i].split()[3]
            sza[i] = round(float(list1[i].split()[0]) * 180/pi)
            #saa[i] = list1[i].split()[2]
            saa[i] = saa_true
            vaa[i] = saa_true - round(float(list1[i].split()[2]) * 180/pi)
            vza[i] = round(float(list1[i].split()[1]) * 180/pi)
            if vaa[i] == azim:
                vza[i] = round(-1 * float(list1[i].split()[1]) * 180/pi)

        #print vza[70]
        for i in range(1, 76):
            f_state = '/media/sf_JRC/RAMI/data/'+f_result+str(i)+'.dat'
            f = open(f_state, 'w')
            f.write('#PARAMETERS time mask vza vaa sza saa 650 860 sd-650 sd-860\n')
            f.write(' 1 1 ' + str( vza[i]) +' '+ str(vaa[i]) +' '+ str(sza[i]) +' '+ str(saa[i]) +
            ' '+ str(red[i]) +' '+ str(nir[i]) +' 0.001 0.001')
            f.close()
            cmd = 'eoldas --conf=eoldas_config.conf --conf=' + conf_file + \
            ' --parameter.x.assoc_default.lad=' + str(lad) + \
            ' --parameter.result.filename=/media/sf_JRC/RAMI/output/'+f_result+str(i)+'.params ' + \
            ' --operator.obs.y.result.filename=/media/sf_JRC/RAMI/output/'+f_result+str(i)+'.fwd' + \
            ' --operator.obs.y.state=' + f_state
            print cmd
            self = eoldas.eoldas(cmd)
            print '************************************Solve now!****************************' 
            self.solve(write=True)
            print '************************************Solve was Done!****************************'
    # set up data for this experiment
    file, ideal_gamma,doys,ndvi_clean,ndvi,qa_flag  = \
  prepare(noise=noise,n_per=n_per,\
   obs_off=obs_off,model_order=model_order,\
   sgwindow=sgwindow)

    # set gamma to less than the the theoretical value
    gamma = ideal_gamma * 0.45

    # set op file names
    xfile = 'output/Identity/NDVI_Identity1.params'
    yfile = 'output/Identity/NDVI_fwd1.params'

    # initialise optuions for DA overriding any in config files
    cmd = 'eoldas ' +  \
                ' --conf=config_files/eoldas_config.conf --conf=config_files/Identity.conf ' + \
                ' --logfile=mylogs/Identity.log ' + \
                ' --calc_posterior_unc ' + \
                ' --parameter.solve=0,1 ' + \
  ' --parameter.result.filename=%s '%xfile +\
                ' --parameter.x.default=%f,0.0 '%(gamma) + \
  ' --operator.obs.y.result.filename=%s'%yfile +\
                ' --operator.obs.y.state=%s'%file+\
                ' --operator.modelt.rt_model.model_order=%d '%model_order

    # initialise eoldas
    self = eoldas.eoldas(cmd)
    # solve DA
    self.solve(write=True)
    cmd = 'eoldas ' +  \
                ' --conf=eoldas_config.conf --conf=confs/IdentitySpatial2a.conf ' + \
                ' --logfile=mylogs/IdentitySpatial.log ' + \
                ' --calc_posterior_unc ' + \
                ' --parameter.solve=0,0,1 ' + \
		' --parameter.result.filename=%s '%xfile +\
                ' --parameter.x.default=%f,%f,0.0 '%(gamma,gamma) + \
		' --operator.obs.y.result.filename=%s'%yfile +\
                ' --operator.obs.y.state=%s'%file+\
                ' --operator.obsc.y.result.filename=%s'%yfile2 +\
                ' --operator.obsc.y.state=%s'%file2+\
                ' --parameter.x.state=%s'%file+\
                ' --operator.modelr.rt_model.model_order=%d '%model_order +\
                ' --operator.modelc.rt_model.model_order=%d '%model_order
    # initialise eoldas
    self = eoldas.eoldas(cmd)
    # solve DA
    self.solve(write=True)
    # ok, now read the results back in
    fwd = (np.array([i.split() for i in open(xfile).readlines()[1:]]).astype(float))
    fwdndvi = fwd[:,5].reshape(ndvi_clean.shape)
    fwdndvisd = fwd[:,8].reshape(ndvi_clean.shape)

    import pylab as plt

    plt.clf()
    plt.xlabel('original ndvi')
    plt.ylabel('modelled ndvi')
    plt.plot([0,1],[0.,1.],'k')
    plt.xlim(0,1)
    plt.ylim(0,1)
예제 #4
0
import eoldas
import sys, tempfile
import os

gamma = 100 / np.sqrt(28.)
model_order = 1
BRF = 'data/brdf_WW_1_A_1.kernelFiltered.dat'

names = 'gamma_time,xlai, xhc,  rpl,  xkab, scen, xkw, xkm,   xleafn, xs1,xs2,xs3,xs4,lad'
default = '%f,0.99,5,0.01,0.99,0.001,0.99,0.35,1.5,1,0.001,0,0,5' % gamma

#default = '%f,0.99,5,0.01,0.5,0.001,0.5,0.35,1.5,1,0.001,0,0,5'%gamma

cmd = 'eoldas ' +  \
                '--conf=config_files/eoldas_config.conf  ' + \
                '--conf=config_files/semid_default.conf ' + \
                '--parameter.x.default=%s '%default + \
                '--parameter.solve=0,1,0,0,1,1,1,1,1,1,1,0,0,0 ' +\
                '--logfile=logs/file.log ' + \
                '--parameter.limits=[[1,365,28]] ' +\
                '--parameter.result.filename=output/gamma%f/state.dat '%gamma + \
                '--operator.obs.y.result.filename=output/gamma%f/obs.dat '%gamma + \
                '--operator.obs.y.state=%s '%BRF + \
                '--operator.modelt.rt_model.model_order=%d '%model_order + \
                '--calc_posterior_unc'

# initialise eoldas
m = eoldas.eoldas(cmd)
# solve DA
m.solve(write=True)
예제 #5
0
  def solveSingle(self,ifile,ofile,initial=None,cmdLine=None):
    '''
    Use eoldas to solve for parameter estimates using 
    observations in ifile, writing result to ofile.

    In this case, there is no temporal constraint, so only a very weak
    prior (see configuration file) is used and we solve for each day's observation 
    sequentially.

    ifile        : input observations file
    ofile        : output parameter file

    Options:
      initial    : starting point (default is None, so start at the priors
                   defined in the configuration file)

    '''
    cmd = self.DefaultCmd

    if initial:
      #set up a new conf to give this
      str = '''
[parameter.x]
state = %s
      '''%initial
      pid = '%s'%(os.getpid())

      conf2 = 'tmp/c4' + pid
      self.mkdir(conf2)
      open(conf2,'w').write(str)
      iheader,idata = self.readParameters(initial)
      isdata = {}
      for i,h in enumerate(iheader.split()):
        isdata[h] = idata[:,i]
      idoys = isdata['time']
      cmd += ' --conf=%s '%conf2

    if cmdLine: cmd += ' ' + cmdLine
    # read the input file
    header,data = self.readParameters(ifile)
    sdata = {}
    for i,h in enumerate(header.split()):
      sdata[h] = data[:,i]
    doys = sdata['time']

    costs = []
    # something wrong here I think, but doesnt matter as we dont want them anyway
    # so effectively sends them to /dev/null I think
    opfile = tempfile.NamedTemporaryFile().name
    fwdFile = tempfile.NamedTemporaryFile().name
    pFile = tempfile.NamedTemporaryFile().name

    for i,d in enumerate(doys):
      if i == 0:
        fwdCmd = "eoldas --conf=config_files/eoldas_config.conf --conf=%s %s "%(self.confFile,cmd) + \
          "--operator.obs.y.result.filename=%s "%fwdFile + \
          "--operator.obs.y.state=%s "%ifile + \
          "--operator.prior.y.result=%s "%pFile + \
          "--logfile=logs/rseSolveSingle.log --no_init_test --plotmod=1e20 --no_doplot --optimisation.gtol=1e-10 " + \
          "--parameter.limits=[[%d,%d,1]] "%(d,d) + \
          "--parameter.result.filename=%s "%opfile

        eo = eoldas.eoldas(fwdCmd)
        prior = truth = eo.solver.root.x.state
        #eo.solver.root.x.state = prior
        eo.solve(write=True,unc=True)
        # get  the tmp op file
        theader,tdata = self.readParameters(opfile)
        data = np.zeros((len(doys),len(theader.split()))) 
        data[i,:] = tdata
        this = np.array([eo.solver.root.x.state[0],eo.solver.root.x.sd]).flatten()
        npm = len(this)
      else:
        # just load the new observation
        # into eo.solver.root.operators[1].y.state
        for k in xrange(len(eo.solver.root.operators)):
          if eo.solver.root.operators[k].thisname == 'eoldas.solver.eoldas.solver-obs':
            for j,b in enumerate(self.bands):
              eo.solver.root.operators[k].y.state[0][j] = sdata[b].flatten()[i]
            # load angles & mask (control data)
            # need to indicate a reload needed for metadata
            eo.solver.root.operators[k].isLoaded = False
            for j,b in enumerate(eo.solver.root.operators[k].y_meta.control):
              eo.solver.root.operators[k].y.control[0][j] = sdata[b][i]
        if initial == None:
          eo.solver.root.x.state[0,1:] = 0.5*(prior[0,1:] + eo.solver.root.x.state[0,1:])
        else:
          thisd = np.where(np.in1d(idoys,d))[0]
          for j,nn in enumerate(eo.solver.names):
            eo.solver.root.x.state[0,j] = isdata[nn][thisd][0]
        truth = eo.solver.root.x.state[0].copy()
        eo.solve(write=False,unc=True)
        data[i,-npm:] = np.array([eo.solver.root.x.state[0],eo.solver.root.x.sd]).flatten()
      try:
        costs.append(eo.solver.min_cost[0])
      except:
        costs.append(eo.solver.min_cost)
      #print i,d,'cost',eo.solver.min_cost[0]
      #print 'data ',eo.solver.root.x.state[0]
      if initial:
        print 'truth',truth
    data[:,0] = doys
    self.data = data
    self.header = header
    self.eoldas = eo
    self.costs = costs
    self.writeParameters(ofile,theader,data)
예제 #6
0
  def solveRegular(self,ifile,ofile,modelOrder=1,gamma=None,initial=None):
    '''
    Use eoldas to solve for parameter estimates using 
    observations in ifile, writing result to ofile.

    In this case, there is no temporal constraint, so only a very weak
    prior (see configuration file) is used and we solve for each day's observation 
    sequentially.

    ifile        : input observations file
    ofile        : output parameter file

    Options:
      modelOrder : regularisation model order (e.g. 1 or 2 (default 1)
      gamma      : gamma value (default whatever set on initialisation or 
                   in initial file). If set to 0 then no regularisation is
                   performed.
      initial    : starting point (default is None, so start at the priors
                   defined in the configuration file)

    '''
    if gamma:
      self.gamma = gamma
    cmd = self.DefaultCmd

    #set up a new conf to give this
    str = '''
[operator]
modelt.name=DModel_Operator
modelt.datatypes = x

[operator.modelt.x]
names = $parameter.names
sd = [1.0]*len($operator.modelt.x.names)
datatype = x

[operator.modelt.rt_model]
model_order=%s
wraparound=periodic,365

    '''%(modelOrder)
    pid = '%s'%(os.getpid())

    if gamma: 
      conf2 = 'tmp/c2' + pid
      self.mkdir(conf2)
      cmd += ' --conf=%s '%conf2
      open(conf2,'w').write(str)

    if initial:
      conf2 = 'tmp/c1'+ pid
      initfile = 'tmp/c3' + pid
      self.mkdir(initfile)
      #set up a new conf to give this
      str = '''
[parameter.x]
state = %s
    '''%(initfile)      
      open(conf2,'w').write(str)
      iheader,idata = self.readParameters(initial)
      isdata = {}
      for i,h in enumerate(iheader.split()):
        isdata[h] = idata[:,i]
      idoys = isdata['time']
      cmd += ' --conf=%s '%conf2
      # fix the gamma value in this file to what we want it to be
      if gamma:
        isdata['gamma_time'] = self.gamma
      for i,h in enumerate(iheader.split()):
        idata[:,i] = isdata[h]
      self.writeParameters(initfile,iheader,idata)

    # read the input file
    header,data = self.readParameters(ifile)
    sdata = {}
    for i,h in enumerate(header.split()):
      sdata[h] = data[:,i]
    doys = sdata['time']

    opfile = ofile + '_result.dat'
    fwdFile = ofile + '_fwd.dat'
    pFile = opfile + '_prior.dat'

    fwdCmd = "eoldas --conf=config_files/eoldas_config.conf --conf=%s %s "%(self.confFile,cmd) + \
          "--operator.obs.y.result.filename=%s "%fwdFile + \
          "--operator.obs.y.state=%s "%ifile + \
          "--operator.prior.y.result=%s "%pFile + \
          "--logfile=logs/rseSolve.log --no_init_test --plotmod=50 --optimisation.gtol=1e-10 " + \
          "--parameter.result.filename=%s "%opfile

    eo = eoldas.eoldas(fwdCmd)
    eo.solve(write=True,unc=True)
예제 #7
0
  def fwdModel(self,ifile,ofile, \
                    lat='50:0', lon='0:0', year='2011', maxVza=15.0, \
                    minSD=0.004, maxSD=0.01,fullBand=False, \
                    every=5,prop=1.0,WINDOW=1):
    '''
    Generate a fwd modelling (reflectrance data) using the parameters in ifile
    writing out to ofile.

    ifile    : input data (parameters) file
    ofile    : output reflectance data file

    Options:
      lat        : latitude (default '50:0') (see ephem)
      lon        : longitude (default ''0:0') (see ephem)
      year       : as int or string (default '2011')
      maxVza     : maximum view zenith angle assumed (15 degrees default)
      minSD      : minimum noise
      maxSD      : maximum noise. The uncertainty in each waveband is scaled linearly
                   with wavelength between minSD and maxSD 
      fullBand   : set True if you want full band pass else False (default False)
                   Note that its much slower to set this True.
      every      : sample output every 'every' doys (default 5)
      prop       : proportion of clear sample days (default 1.0)
      WINDOW     : size of smoothing kernel to induce temporal correlation in 
                   data gaps if prop < 1
    '''
    this = self.loadData(ifile)
    self.doys = this['time']


    self.mask = np.zeros_like(self.doys).astype(bool)
    self.datastr = 'time '

    # sub sample
    self.sdoys = self.doys[self.doys%every == 1]

    # apply gaps
    #WINDOW = 1
    weightings = np.exp(-((np.arange(WINDOW*2+1)-WINDOW)/(WINDOW/3./every))**2)
    weightings /= weightings.sum()
    l = len(self.sdoys)
    xx = np.convolve(np.random.rand(l*(1+50*WINDOW)),weightings,'valid')[WINDOW*30+WINDOW:WINDOW*30+WINDOW+l]

    maxx = sorted(xx)[:int(len(xx)*prop)]
    mask = np.in1d(xx,maxx)
    self.sdoys = self.sdoys[mask]

    # generate data
    l = len(self.sdoys)
    self.sdata = np.zeros([l,1 + len(self.bands)*2+len(self.control)])
    self.sdata[:,0] = self.sdoys
    o = ephem.Observer()
    o.lat, o.long, o.date = lat, lon , datetime.datetime(int(year), 1, 1, 10, 30)
    sun = ephem.Sun(o)
    dd = o.date

    for (n,i) in enumerate(self.control):
      self.datastr += ' %s'%i
      if i == 'mask':
        self.sdata[:,n+1] = 1
      elif i == 'vaa' or i == 'saa':
        self.sdata[:,n+1] = np.random.rand(l)*360.
      elif i == 'vza':
        self.sdata[:,n+1] = np.random.rand(l)*maxVza
      else:
        dates = dd + self.sdoys
        for (m,j) in enumerate(dates):
          o.date = j
          sun = ephem.Sun(o)
          self.sdata[m,n+1] = 90 - float(sun.alt) * 180./np.pi

    for (n,i) in enumerate(self.bands):
      self.datastr += ' %s'%i

    i = self.bands[0]
    this0 = this = np.array([float(j) for j in i.split('-')]).mean()
    i = self.bands[-1]
    this1 = np.array([float(j) for j in i.split('-')]).mean()

    ostr = ''
    nstr = ''
    # sort the sd info
    for (n,i) in enumerate(self.bands):
      ostr = ostr + "%12.6f"%0.0
      this = minSD + (maxSD - minSD) * (np.array([float(j) for j in i.split('-')]).mean() - this0)/(this1 - this0)
      nstr = nstr + "%12.6f"%this
      self.datastr += ' sd-%s'%i
      self.sdata[:,1+len(self.control)+len(self.bands)+ n] = this

    # write out a first version of the observations file   
    self.writeParameters(ofile,self.datastr,self.sdata) 

    ############################################
    # Generate the clean synthetic observations
    ############################################

    # we ingest the state vector data (ifile)
    # and the angle / observation data (ofile)
    # and produce fwdFile that has the (clean) fwd observations
    # but doesn't have the uncertainty information
    # Note that we can switch use_median False, which
    # means that the full bandpass is used in fwd modelling
    pid = '%s'%(os.getpid())
    fwdFile = ofile + '.tmp' + pid
    fwdData = ifile + '.tmp' + pid
    if fullBand:
      option = "--operator.obs.rt_model.no_use_median "
    else:
      option = ""

    fwdCmd = "eoldas --conf=config_files/eoldas_config.conf --conf=config_files/sentinel0.conf  --passer " + \
                "--operator.obs.y.result.filename=%s "%fwdFile + \
                "--operator.obs.y.state=%s "%ofile + \
                "--logfile=logs/rseFwd.log %s "%option + \
                "--parameter.result.filename=%s "%fwdData + \
                "--conf=config_files/sentinel1.conf --parameter.x.state=%s "%ifile

    self = eoldas.eoldas(fwdCmd)
    # write fwd file
    self.solver.write()
    self.solver.writeHx()

    # we now put the observation uncertainty information in
    # combination with the observation data in fwdFile
    # to give the clean observations in op
    ip = fwdFile
    op = ofile
    f = open(ip,'r')
    f2 = open(op,'w')

    this = f.readlines()
    that = [i.replace(ostr,nstr)  for i in this]

    f2.writelines(that)
    f.close()
    f2.close()
예제 #8
0
파일: misr_8.py 프로젝트: maxchernet/MISR
def do_misr_eoldas(bands, sds, out_dir, prefix, data_misr, data_misr_real, data_etm, real):
        #Read data from the JRC-csv files and save them in EO-LDAS *.brf files
        misr_ang = save_dat(save_path = data_misr_real)
        misr_ang = np.array([misr_ang]).astype(float)[0,:,:]
        for n_field in [0]:#xrange(18):
                #leaf angle distribution (lad) is fixed and it
                #different for each crop
                xlad = [1,1,5,2,2,2,2,2,2,2,2,5,5,1,1,1,1,1]
                #misr_ang = 
                n_ang = misr_ang.shape[1]
                #get a state for generation of synth data
                params, field = get_state()
                if real==0:
                        #Create synthetic data set. It uses the same geometry as real MISR data
                        create_synth(n_field, params[n_field,:], misr_ang, data_misr)

                #Do a first guess
                #If we have MISR only
                if data_etm == '': 
                        n_b=4
                        #Make a distribution
                        distr_file = '/home/max/misr/misr_distr_1'
                        ang_arr = [16.59, 284.22, 22.02, 319.10]
                #If we have MISR and ETM+
                else: 
                        n_b=6
                        #Make a distribution
                        distr_file = '/home/max/misr/etm_distr_1'
                        ang_arr = [16.0, 8.0, 26.65, 301.0]
                #create_distr(distr_file, ang_arr)
                #read train dataset from a file
                npzfile = np.load(distr_file+'.npz')
                #load train state parameters
                x_train = npzfile['arr_0']
                #train reflectance
                brf_train = npzfile['arr_1']
                real_misr = np.zeros((n_ang, n_b))
                #read synthetic or real satellite data created
                #on previous step
                for i in range(1, n_ang+1):
                    if data_etm == '':
                        #Open MISR data file (actually we use only nadir but here we read all view angles)
                        f = open(data_misr+'misr_P201_B059_2004.7.16_chl%d_ang%d.brf'%(n_field+1, i))
                    else:
                        #Open ETM+ data file (actually we use only nadir but here we read all view angles)
                        f = open(data_etm+'etm_chl%d.brf'%(n_field+1))

                    #nunmber if bands
                    tmp_lst = f.read().split('\n')
                    f.close()
                    real_misr[i-1,:] = tmp_lst[1].split()[6:6+n_b]
                    #it dependa on a number of bands
                    wl= tmp_lst[0].split()[3:3+n_b]
                wl = np.array(wl).astype(float)
                train_misr=[]
                #Reduce number of bands of trained dataset to 
                #a nummber of bands of satellite data
                for i in xrange(wl.size):
                    tmp = brf_train[:,wl[i]-400]
                    train_misr.append(tmp)
                train_misr = np.array(train_misr)
                #Find sum of difference
                sum_misr=[]
                n_train = brf_train.shape[0]
                for i in xrange(n_train):
                    sum_misr.append(np.sum(abs(real_misr[0,:] - train_misr[:,i])))
                #Find a minimum and this is an end of first guess
                min_i = np.argmin(sum_misr)

                #Initial values = first guess
                gamma_time = 0.05
                xlai = x_train[min_i,0]
                xhc = x_train[min_i,1]
                rpl = x_train[min_i,2]
                xkab = x_train[min_i,3]
                scen = x_train[min_i,4]
                xkw = x_train[min_i,5]
                xkm = x_train[min_i,6]
                xleafn = x_train[min_i,7]
                xs1 = x_train[min_i,8]
                xs2 = x_train[min_i,9]
                xs3 = 0
                xs4 = 0
                lad = xlad[n_field]

                #Prior values in Ordered dictonary
                prior = OrderedDict([('xlai', 0.37), \
                           ('xhc', 1.0),\
                           ('rpl', 0.15), \
                           ('xkab', 0.6),\
                           ('scen', 0.5),\
                           ('xkw', 0.6),\
                           ('xkm', 0.37),\
                           ('xleafn', 1.5),\
                           ('xs1', 1.0),\
                           ('xs2', 0),\
                           ('xs3', 0),\
                           ('xs4', 0),
                           ('lad', 1)])
                #Prior uncertainties
                prior_sd = OrderedDict([('xlai', 1.), \
                           ('xhc', 3.),\
                           ('rpl', 0.15), \
                           ('xkab', 0.4),\
                           ('scen', 0.5),\
                           ('xkw', 0.5),\
                           ('xkm', 0.7),\
                           ('xleafn', 1.),\
                           ('xs1', 3.),\
                           ('xs2', 2.),\
                           ('xs3', 0.001),\
                           ('xs4', 0.001),
                           ('lad', 0.001)])

                #Inicialize string with first values (LAI) from ordered dic
                prior_str = prior.values()[0]
                prior_sd_str = prior_sd.values()[0]
                #Make a strings with all other values from ordered dic
                for i in list(prior.values()[1:]): 
                        prior_str = '%s,%.3f'%(prior_str, i)
                for i in list(prior_sd.values()[1:]): 
                        prior_sd_str = '%s,%.3f'%(prior_sd_str, i)

                #lists of bands and sdandard deviations
                #bands = ['443.0 555.0 670.0 865.0']
                #sds = ['0.0040 0.0044 0.0047 0.0054']
                #483.0 560.0 662.0 835.0 1648.0 2206.0
                #0.0041 0.0045 0.0047 0.0053 0.0079 0.0097
                #out_dir = '/home/max/misr/out_synth_misr_75ang/'
                for i in xrange(1,n_ang+1):
                        #Define input an output files depending on one sensor or two sensors are used
                        if len(data_etm)=='':
                                f_state = [data_misr+'misr_P201_B059_2004.7.16_chl%d_ang%d.brf'%(n_field+1, i)]
                                f_result = [out_dir + 'misr_P201_B059_2004.7.16_chl%d_ang%d_brf.fwd'%(n_field+1, i)]
                        else:
                                f_state = [data_misr+'misr_P201_B059_2004.7.16_chl%d_ang%d.brf'%(n_field+1, i),\
                                        data_etm+'etm_chl%d.brf'%(n_field+1)]
                                f_result = [out_dir + 'misr_P201_B059_2004.7.16_chl%d_ang%d_brf.fwd'%(n_field+1, i),\
                                        out_dir + 'etm_chl%d.fwd'%(n_field+1)]
                        #f_state = ['/home/max/misr/data_misr_synth_75ang/misr_P201_B059_2004.7.16_chl%d_ang%d.brf'%(n_field+1, i)]
                        #f_result = [out_dir + '/misr_synth_P201_B059_2004.7.16_chl%d_ang%d_brf.fwd'%(n_field+1, i)]

                        f_result_param = out_dir + prefix+'_P201_B059_2004.7.16_chl%d_ang%d_brf.params'%(n_field+1, i)
                        f_prior = out_dir + prefix+'_P201_B059_2004.7.16_chl%d_ang%d_brf.prior'%(n_field+1, i)
                        #Name of a conf. file
                        conf_file = '/home/max/misr/conf/misr-etm_obs%d.conf'%len(bands)
                        #Make a config file
                        conf_file = do_config(conf_file, n_obs=len(bands), bands=bands, sds=sds, lst_state=f_state, lst_result=f_result, f_result_param=f_result_param, f_prior=f_prior)
                        print 'conf_file', conf_file
                        #Do inversion
                        #Command line
                        cmd = 'eoldas --conf=conf/eoldas_config.conf --conf=' + conf_file +\
                        ' --parameter.x.default=[%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f]'%(gamma_time, xlai, xhc, rpl, xkab, scen, xkw, xkm, xleafn, xs1, xs2, xs3, xs4, lad) + \
                        ' --operator.prior.y.sd=%s'%prior_sd_str + \
                        ' --operator.prior.y.state=[%s]'%prior_str + \
                        ' --logfile=/media/sf_JRC/log/misr_01.log'
                        self = eoldas.eoldas(cmd)
                        self.solve(write=True)
                        print 'Done inversion!'
예제 #9
0
import sys,tempfile
import os

gamma = 100/np.sqrt(28.)
model_order = 1
BRF = 'data/brdf_WW_1_A_1.kernelFiltered.dat'

names = 'gamma_time,xlai, xhc,  rpl,  xkab, scen, xkw, xkm,   xleafn, xs1,xs2,xs3,xs4,lad'
default = '%f,0.99,5,0.01,0.99,0.001,0.99,0.35,1.5,1,0.001,0,0,5'%gamma

#default = '%f,0.99,5,0.01,0.5,0.001,0.5,0.35,1.5,1,0.001,0,0,5'%gamma

cmd = 'eoldas ' +  \
                '--conf=config_files/eoldas_config.conf  ' + \
                '--conf=config_files/semid_default.conf ' + \
                '--parameter.x.default=%s '%default + \
                '--parameter.solve=0,1,0,0,1,1,1,1,1,1,1,0,0,0 ' +\
                '--logfile=logs/file.log ' + \
                '--parameter.limits=[[1,365,28]] ' +\
                '--parameter.result.filename=output/gamma%f/state.dat '%gamma + \
                '--operator.obs.y.result.filename=output/gamma%f/obs.dat '%gamma + \
                '--operator.obs.y.state=%s '%BRF + \
                '--operator.modelt.rt_model.model_order=%d '%model_order + \
                '--calc_posterior_unc'

# initialise eoldas
m = eoldas.eoldas(cmd)
# solve DA
m.solve(write=True)