예제 #1
0
for i,[site_name,oblock,mblock] in enumerate(zip(site_names,oblocks,mblocks)):        
        oblock = [oblock]
        mblock = [mblock]
        
        #--get the starting and end date of each record within the reduced model sim time
        rstart,rend = hobs_start[site_name],hobs_end[site_name]        
        if rend > start:                                                 
            #--find the date range for this record and write date files
            dstart,dend = max(start,rstart),min(end,rend)
            print site_name,dstart,dend
            week_file = date_dir+site_name+'_wk.dat'
            full_file = date_dir+site_name+'.dat'
            dry_file = date_dir+site_name+'_dry.dat'
            #tc.write_date_file(week_file,dstart+timedelta(days=7),dend-timedelta(days=7),timedelta(days=7))
            tc.write_date_file(full_file,dstart,dend,None)                                            
            
            
            uniform_days = tsp.new_series_uniform([oblock[0].name],dstart+timedelta(days=7),dend)
            biweekly_days = tsp.new_series_uniform([oblock[0].name],dstart+timedelta(days=14),dend,interval=14,suffix='ub')
            #weekly_block = tsp.series_avg(relative_block,week_file,context=tc.PEST_CONTEXT)                            

            #--observation block            
            reduced_block = tsp.reduce_time(oblock,dstart,end_dt=dend,context=tc.PEST_CONTEXT)            
            relative_block = tsp.drawdown(reduced_block,full_file,first=True,context=tc.PEST_CONTEXT)  
            interp_block = tsp.new_time_base(relative_block,uniform_days,context=tc.PEST_CONTEXT)     
            filter_block = tsp.baseflow_filter(interp_block,context=tc.PEST_CONTEXT)
            diff_block = tsp.difference_2_series(interp_block,filter_block,context=tc.PEST_CONTEXT)
            bi_block = tsp.new_time_base(diff_block,biweekly_days,context=tc.PEST_CONTEXT,suffix='bi')                           
                        
            
pred_start = grid.sp_end[-2]
pred_end = grid.end

date_dir = 'date_files\\'
tsproc_infile = 'tsproc_setup.dat'
tsp = tc.tsproc(tsproc_infile,out_file='processed.dat',out_fmt='long')

pest_oblocks,pest_mblocks = [],[]
hobs_file = '_misc\\heads.smp'
hobs_smp = pu.smp(hobs_file,date_fmt=tc.DATE_FMT,load=True)

mobs_file = 'mheads.smp'
mobs_smp = pu.smp(mobs_file,date_fmt=tc.DATE_FMT,load=True)

full_file = date_dir+'full_range.dat'
tc.write_date_file(full_file,obs_start,obs_end,None)                                            

pred_file = date_dir+'pred_range.dat'
tc.write_date_file(pred_file,pred_start,pred_end,None)                                            


#--swr - for prediction
ost_names = ['obf_1']
mst_names = ['mbf_1']
rgp_nums = [1]

mblocks = tsp.get_mul_series_swr(rgp_nums,'qbflow','_model\\simple.fls',grid.start,series_name_list=mst_names)
oblocks = tsp.get_mul_series_swr(rgp_nums,'qbflow','_model\\simple.fls',grid.start,context=tc.PEST_CONTEXT,series_name_list=ost_names)
obf_blocks = tsp.copy_2_series(oblocks,['obf'],role='final',wght=0.0,context=tc.PEST_CONTEXT)
mbf_blocks = tsp.copy_2_series(mblocks,['mbf'],role='final',wght=0.0)
pest_oblocks.extend(obf_blocks)
pred_start = grid.sp_end[-2]
pred_end = grid.end

date_dir = 'date_files\\'
tsproc_infile = 'tsproc_setup.dat'
tsp = tc.tsproc(tsproc_infile, out_file='processed.dat', out_fmt='long')

pest_oblocks, pest_mblocks = [], []
hobs_file = '_misc\\heads.smp'
hobs_smp = pu.smp(hobs_file, date_fmt=tc.DATE_FMT, load=True)

mobs_file = 'mheads.smp'
mobs_smp = pu.smp(mobs_file, date_fmt=tc.DATE_FMT, load=True)

full_file = date_dir + 'full_range.dat'
tc.write_date_file(full_file, obs_start, obs_end, None)

pred_file = date_dir + 'pred_range.dat'
tc.write_date_file(pred_file, pred_start, pred_end, None)

#--swr - for prediction
ost_names = ['obf_1']
mst_names = ['mbf_1']
rgp_nums = [1]

mblocks = tsp.get_mul_series_swr(rgp_nums,
                                 'qbflow',
                                 '_model\\simple.fls',
                                 grid.start,
                                 series_name_list=mst_names)
oblocks = tsp.get_mul_series_swr(rgp_nums,