Example #1
0
pnum = 0
CNP_parms = ['ks_sorption', 'r_desorp', 'r_weather', 'r_adsorp', 'k_s1_biochem', 'smax', 'k_s3_biochem', \
             'r_occlude', 'k_s4_biochem', 'k_s2_biochem']

fates_seed_zeroed = [False, False]
for p in parm_names:
    if ('INI' in p):
        if ('BGC' in casename):
            scalevars = ['soil3c_vr', 'soil3n_vr', 'soil3p_vr']
        else:
            scalevars = ['soil4c_vr', 'soil4n_vr', 'soil4p_vr']
        sumvars = ['totsomc', 'totsomp', 'totcolc', 'totcoln', 'totcolp']
        for v in scalevars:
            myvar = nffun.getvar(finidat_file_new, v)
            myvar = parm_values[pnum] * myvar
            ierr = nffun.putvar(finidat_file_new, v, myvar)
    elif (p == 'lai'):
        myfile = surffile
        param = nffun.getvar(myfile, 'MONTHLY_LAI')
        param[:, :, :, :] = parm_values[pnum]
        ierr = nffun.putvar(myfile, 'MONTHLY_LAI', param)
    elif (p != 'co2'):
        if (p in CNP_parms):
            myfile = CNPfile
        elif ('fates' in p):
            myfile = fates_paramfile
        else:
            myfile = pftfile
        param = nffun.getvar(myfile, p)
        if (('fates_prt' in p and 'stoich' in p)
                or ('fates_turnover' in p and 'retrans' in p)):
Example #2
0
pnum = 0
CNP_parms = ['ks_sorption', 'r_desorp', 'r_weather', 'r_adsorp', 'k_s1_biochem', 'smax', 'k_s3_biochem', \
             'r_occlude', 'k_s4_biochem', 'k_s2_biochem']

fates_seed_zeroed=[False,False]
for p in parm_names:
   if ('INI' in p):
      if ('BGC' in casename):
         scalevars = ['soil3c_vr','soil3n_vr','soil3p_vr']
      else:
         scalevars = ['soil4c_vr','soil4n_vr','soil4p_vr']
      sumvars = ['totsomc','totsomp','totcolc','totcoln','totcolp']
      for v in scalevars:
         myvar = nffun.getvar(finidat_file_new, v)
         myvar = parm_values[pnum] * myvar
         ierr = nffun.putvar(finidat_file_new, v, myvar)
   elif (p == 'lai'):
     myfile = surffile
     param = nffun.getvar(myfile, 'MONTHLY_LAI')
     param[:,:,:,:] = parm_values[pnum]
     ierr = nffun.putvar(myfile, 'MONTHLY_LAI', param)
   elif (p != 'co2'):
      if (p in CNP_parms):
         myfile= CNPfile
      elif ('fates' in p):
         myfile = fates_paramfile
      else:
         myfile = pftfile
      param = nffun.getvar(myfile,p)
      if ('fates_prt_nitr_stoich_p1' in p):
        #this is a 2D parameter.
Example #3
0
        area = nffun.getvar(domainfile_new, 'area')
        frac[0] = 1.0
        mask[0] = 1
        if (options.site != ''):
            xc[0] = lon[n]
            yc[0] = lat[n]
            xv[0][0][0] = lon[n] - resx / 2
            xv[0][0][1] = lon[n] + resx / 2
            xv[0][0][2] = lon[n] - resx / 2
            xv[0][0][3] = lon[n] + resx / 2
            yv[0][0][0] = lat[n] - resy / 2
            yv[0][0][1] = lat[n] - resy / 2
            yv[0][0][2] = lat[n] + resy / 2
            yv[0][0][3] = lat[n] + resy / 2
            area[0] = resx * resy * math.pi / 180 * math.pi / 180
            ierr = nffun.putvar(domainfile_new, 'xc', xc)
            ierr = nffun.putvar(domainfile_new, 'yc', yc)
            ierr = nffun.putvar(domainfile_new, 'xv', xv)
            ierr = nffun.putvar(domainfile_new, 'yv', yv)
            ierr = nffun.putvar(domainfile_new, 'area', area)

        ierr = nffun.putvar(domainfile_new, 'frac', frac)
        ierr = nffun.putvar(domainfile_new, 'mask', mask)
        os.system('ncks -O --mk_rec_dim nj ' + domainfile_new + ' ' +
                  domainfile_new)
    elif (options.mymask != ''):
        print 'Applying mask from ' + options.mymask
        os.system('ncks -d lon,'+str(xgrid_min[n])+','+str(xgrid_max[n])+' -d lat,'+str(ygrid_min[n])+ \
               ','+str(ygrid_max[n])+' '+options.mymask+' mask_temp.nc')
        newmask = nffun.getvar('mask_temp.nc', 'PNW_mask')
        ierr = nffun.putvar(domainfile_new, 'mask', newmask)
Example #4
0
  for v in range(0,len(var_names_harvest)):	
    rest_vals = nffun.getvar(fname_restart, var_names_harvest[v].lower())
    #Loop through all valid values in the restart file.
    n_rest = len(rest_vals)
    for i in range(0,n_rest):
      rest_vals[i] = rest_vals[i]*0.05
      if (var_names_harvest[v] == 'LEAFC'):
        rest_vals[i] = 0.33/0.03
        print(rest_vals[i])
      elif (var_names_harvest[v] == 'FROOTC'):
        rest_vals[i] = 0.33/0.03*0.666
      elif (var_names_harvest[v] == 'LEAFN'):
        rest_vals[i] = 0.33/0.03/25.0
      elif (var_names_harvest[v] == 'FROOTN'):
        rest_vals[i] = 0.33/0.03/42.0
    ierr = nffun.putvar(fname_restart, var_names_harvest[v].lower(), rest_vals)
else:
  for v in range(0,len(var_names)):
    hist_vals = nffun.getvar(fname_hist, var_names[v])
    rest_vals = nffun.getvar(fname_restart, var_names[v].lower())
    #Loop through all valid values in the restart file.
    n_rest = len(rest_vals)
    for i in range(0,n_rest):
      if (float(rest_vals[i]) > 0.0 and float(hist_vals[0][i]) < 1.0e10 and float(hist_vals[0][i]) > 0.001):
        rest_vals[i] = hist_vals[0][i]
    ierr = nffun.putvar(fname_restart, var_names[v].lower(), rest_vals)

  #get a single, non-depth dependent variable to count # of columns
  rest_vals = nffun.getvar(fname_restart, 'fpg')
  n_rest = len(rest_vals) 
  for v in range(0,len(var_names2d)):