Beispiel #1
0
def main(experiment_id):
    
    # --- FILE PATHS, DIR NAMES ETC --- #
    base_dir = ""
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "forcing")
    run_dir = os.path.join(base_dir, "runs")
    
    # --- CHANGE PARAM VALUES ON THE FLY --- #
    itag = experiment_id + "_example"
    otag = experiment_id + "_example_sim"
    mtag = "met_data.gin"
    out_fn = "EXAMPLE.csv"
    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)
    replace_dict = { 
                     "out_param_fname": '"%s"' % (out_param_fname),
                     "cfg_fname": '"%s"' % (cfg_fname),
                     "met_fname": '"%s"' % (met_fname),
                     "out_fname": '"%s"' % (out_fname),
                     "age": "12.0",
                     "print_options": '"daily"',
                     "co2_conc": '"AMB"',
                     "canht": "17.0",   # m
                    }
    ad.adjust_param_file(cfg_fname, replace_dict)
    
    # --- RUN THE MODEL --- #
    G = model.Gday(cfg_fname)
    G.run_sim()
Beispiel #2
0
def main(experiment_id):

    # --- FILE PATHS, DIR NAMES ETC --- #
    base_dir = os.getcwd()
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "forcing")
    run_dir = os.path.join(base_dir, "runs")

    # --- CHANGE PARAM VALUES ON THE FLY --- #
    itag = experiment_id + "_dk_youngforest"
    otag = experiment_id + "_dk_simulation"
    mtag = "nceas_met_AMB.csv"
    out_fn = "D1GDAYDKAMB.csv"
    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)
    replace_dict = {
        # files
        "out_param_fname": '"%s"' % (out_param_fname),
        "cfg_fname": '"%s"' % (cfg_fname),
        "met_fname": '"%s"' % (met_fname),
        "out_fname": '"%s"' % (out_fname),

        # state
        "age": "12.0",

        # control
        "alloc_model": '"fixed"',
        "assim_model": '"mate"',
        "calc_sw_params": "1",  #0 uses fwp values, 1= derive them
        "deciduous_model": '"false"',
        "fixed_stem_nc": "1",
        "fixleafnc": '"false"',
        "grazing": '"false"',
        "model_optroot": '"false"',
        "modeljm": '"true"',
        "nuptake_model": "1",
        "passiveconst": '"false"',
        "print_options": '"daily"',
        "ps_pathway": '"c3"',
        "strfloat": "0",
        "trans_model": "1",
        "use_eff_nc": "0",
        "use_leuning": "0",
        "water_stress": '"true"',
        "sw_stress_model": "1",  # Landsberg
    }
    ad.adjust_param_file(cfg_fname, replace_dict)

    # --- RUN THE MODEL --- #
    G = model.Gday(cfg_fname)
    G.run_sim()

    # translate output to NCEAS style output

    # add this directory to python search path so we can find the scripts!
    sys.path.append(os.path.join(base_dir, "scripts"))
    import translate_GDAY_output_to_NCEAS_format as tr
    tr.translate_output(out_fname, met_fname)
Beispiel #3
0
def main(experiment_id):

    # --- FILE PATHS, DIR NAMES ETC --- #
    base_dir = os.getcwd()
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "forcing")
    run_dir = os.path.join(base_dir, "runs")

    # --- CHANGE PARAM VALUES ON THE FLY --- #
    itag = experiment_id + "_dk_youngforest"
    otag = experiment_id + "_dk_simulation"
    mtag = "nceas_met_AMB.csv"
    out_fn = "D1GDAYDKAMB.csv"
    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)
    replace_dict = {
        # files
        "out_param_fname": '"%s"' % (out_param_fname),
        "cfg_fname": '"%s"' % (cfg_fname),
        "met_fname": '"%s"' % (met_fname),
        "out_fname": '"%s"' % (out_fname),
        # state
        "age": "12.0",
        # control
        "alloc_model": '"fixed"',
        "assim_model": '"mate"',
        "calc_sw_params": "1",  # 0 uses fwp values, 1= derive them
        "deciduous_model": '"false"',
        "fixed_stem_nc": "1",
        "fixleafnc": '"false"',
        "grazing": '"false"',
        "model_optroot": '"false"',
        "modeljm": '"true"',
        "nuptake_model": "1",
        "passiveconst": '"false"',
        "print_options": '"daily"',
        "ps_pathway": '"c3"',
        "strfloat": "0",
        "trans_model": "1",
        "use_eff_nc": "0",
        "use_leuning": "0",
        "water_stress": '"true"',
        "sw_stress_model": "1",  # Landsberg
    }
    ad.adjust_param_file(cfg_fname, replace_dict)

    # --- RUN THE MODEL --- #
    G = model.Gday(cfg_fname)
    G.run_sim()

    # translate output to NCEAS style output

    # add this directory to python search path so we can find the scripts!
    sys.path.append(os.path.join(base_dir, "scripts"))
    import translate_GDAY_output_to_NCEAS_format as tr

    tr.translate_output(out_fname, met_fname)
Beispiel #4
0
def main(experiment_id, site, SPIN_UP=None):
    
    # dir names
    base_param_name = "base_start"
    base_dir = os.getcwd()
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")
    
    
    if SPIN_UP == True:
    
        # copy base files to make two new experiment files
        shutil.copy(os.path.join(param_dir, base_param_name + ".cfg"),                
                    os.path.join(param_dir, "%s_%s_model_spinup.cfg" % \
                    (experiment_id, site)))
        
        # Run model to equilibrium assuming forest, growing C pools from 
        # effectively zero
        itag = "%s_%s_model_spinup" % (experiment_id, site)
        otag = "%s_%s_model_spunup" % (experiment_id, site)
        mtag = "%s_met_data_equilibrium_50_yrs.csv" % (site)
        out_fn = itag + "_equilib.out" 
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        
        replace_dict = { 
                         # files
                         "out_param_fname": '"%s"' % (out_param_fname),
                         "cfg_fname": '"%s"' % (cfg_fname),
                         "met_fname": '"%s"' % (met_fname),
                         "out_fname": '"%s"' % (out_fname),
                         
                         # control - using Fixed allocation coeffs
                         "alloc_model": '"fixed"',
                         "assim_model": '"mate"',
                         "calc_sw_params": '"true"',   #false=use fwp values, true=derive them
                         "deciduous_model": '"false"',
                         "disturbance": "0",
                         "fixed_stem_nc": '"true"',
                         "fixleafnc": '"false"',
                         "grazing": '"false"',
                         "gs_model": '"medlyn"',
                         "model_optroot": '"false"',
                         "modeljm": '"true"',
                         "nuptake_model": "1",
                         "passiveconst": '"false"',
                         "print_options": '"end"',
                         "ps_pathway": '"c3"',
                         "strfloat": "0",
                         "sw_stress_model": "1",  # Sands and Landsberg 
                         "trans_model": "1",
                         "use_eff_nc": "0",
                         "use_leuning": "0",
                         "water_stress": '"true"',
                         
                         # state - default C:N 25.
                         "age": "0.0",
                         "canht": "17.0", # Canopy height increased from 16m in 2001 to 18m in 2004 at Duke
                         "activesoil": "0.001",
                         "activesoiln": "0.00004",
                         "age": "0.0",
                         "branch": "0.001",
                         "branchn": "0.00004",
                         "cstore": "0.001",
                         "inorgn": "0.00004",
                         "metabsoil": "0.0",
                         "metabsoiln": "0.0",
                         "metabsurf": "0.0",
                         "metabsurfn": "0.0",
                         "nstore": "0.00004",
                         "passivesoil": "0.001",
                         "passivesoiln": "0.0004",
                         "prev_sma": "1.0",
                         "root": "0.001",
                         "root_depth": "-9999.9",
                         "rootn": "0.00004",
                         "sapwood": "0.001",
                         "shoot": "0.001",
                         "shootn": "0.00004",
                         "slowsoil": "0.001",
                         "slowsoiln": "0.00004",
                         "stem": "0.001",
                         "stemn": "0.00004",
                         "stemnimm": "0.00004",
                         "stemnmob": "0.0",
                         "structsoil": "0.001",
                         "structsoiln": "0.00004",
                         "structsurf": "0.001",
                         "structsurfn": "0.00004",
                         
                         
                         # parameters
                         "latitude": "35.9",
                         "intercep_frac": "0.15",
                         "max_intercep_lai": "3.0",
                         "albedo": "0.123",   # modis site avg
                         "finesoil": "0.5",  
                         "slamax": "4.6",     # Drake, 2010, PCE, 33, 1756-1766, fig5 (values are in DM and projected, i.e. one sided, what we need for GDAY). Take value for ~20 years. y=47.2-0.063*x
                         "sla": "4.6",    # Drake, 2010, PCE, 33, 1756-1766, fig5 (values are in DM and projected, i.e. one sided, what we need for GDAY). Take value for ~20 years. y=47.2-0.063*x
                         "slazero": "4.6",    # Drake, 2010, PCE, 33, 1756-1766, fig5 (values are in DM and projected, i.e. one sided, what we need for GDAY). Take value for ~20 years. y=47.2-0.063*x
                         "cfracts": "0.5",
                         "cfracts": "0.5",
                         "lai_cover": "0.5",
                         "jmaxn": "60.0",   # Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "vcmaxn": "30.61", # Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "c_alloc_fmax": "0.25",   
                         "c_alloc_fmin": "0.25",
                         "c_alloc_rmax": "0.05", 
                         "c_alloc_rmin": "0.05", 
                         "c_alloc_bmax": "0.2", 
                         "c_alloc_bmin": "0.2",
                         "fretrans": "0.5",  
                         "rretrans": "0.0",  
                         "bretrans": "0.0",  
                         "wretrans": "0.0",
                         "ncwnewz": "0.003",    
                         "ncwnew": "0.003",     
                         "ncwimmz": "0.003",    
                         "ncwimm": "0.003",     
                         "ncbnewz": "0.003",    
                         "ncbnew": "0.003",     
                         "ncrfac": "0.8",     
                         "ncmaxfyoung": "0.06",
                         "ncmaxfold": "0.06",  
                         "ncmaxr": "0.03",     
                         "retransmob": "0.0", 
                         "fdecay": "0.63",   # 19 mth turnover * 1/30, McCarthy, 2007, GCB, 13, 2479-2497  
                         "fdecaydry": "0.63", # 19 mth turnover * 1/30, McCarthy, 2007, GCB, 13, 2479-2497 
                         "rdecay": "0.63",      
                         "rdecaydry": "0.63",   
                         "bdecay": "0.02",      
                         "wdecay": "0.02",      
                         "watdecaydry": "0.0", 
                         "watdecaywet": "0.1", 
                         "ligshoot": "0.25",    
                         "ligroot": "0.25",     
                         "brabove": "0.5",     
                         "rateuptake": "3.0",           # set somewhat (very) arbitarly to get an LAI ~ 4.
                         "rateloss": "0.5",
                         "topsoil_depth": "350.0",     # Not needed as I have supplied the root zone water and topsoil water available
                         "rooting_depth": "750.0",     # Not needed as I have supplied the root zone water and topsoil water available
                         "ctheta_topsoil": "0.5",      # Derive based on soil type clay_loam
                         "ntheta_topsoil": "5.0",      # Derive based on soil type clay_loam
                         "ctheta_root": "0.4",         # Derive based on soil type clay
                         "ntheta_root": "3.0",         # Derive based on soil type clay
                         "topsoil_type": '"clay_loam"',
                         "rootsoil_type": '"clay"',
                         "measurement_temp": "25.0",
                         "dz0v_dh": "0.075", # However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
                         "displace_ratio": "0.78",
                         "g1": "2.74", 
                         "jmaxna": "60.0",  # Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "jmaxnb": "0.0",   # Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "vcmaxna": "30.61",# Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "vcmaxnb": "0.0",  # Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "sapturnover": "0.1",
                         "heighto": "4.826",  
                         "htpower": "0.35",   
                         "height0": "5.0",    
                         "height1": "20.0",   
                         "leafsap0": "8000.0",
                         "leafsap1": "3060.0",  # Duke protocol
                         "branch0": "5.61",   
                         "branch1": "0.346",  
                         "targ_sens": "0.5",  
                         "density": "420.0",  
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        G = model.Gday(cfg_fname, spin_up=True)
        G.spin_up_pools()
Beispiel #5
0
def main(experiment_id, site, treatment, ascii=True):

    # --- FILE PATHS, DIR NAMES ETC --- #
    # base_dir = os.getcwd()
    param_dir = "params"
    met_dir = "met_data"
    run_dir = "outputs"

    # --- CHANGE PARAM VALUES ON THE FLY --- #
    itag = "%s_%s_model_youngforest_%s" % (experiment_id, site, treatment)
    otag = "%s_%s_model_simulation_%s" % (experiment_id, site, treatment)
    mtag = "%s_met_data_%s_co2.csv" % (site, treatment)
    out_fn = "D1GDAY%s%s" + (".csv" if ascii else ".bin")
    # import pdb; pdb.set_trace()
    out_fn = out_fn % (site, treatment.upper())

    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)

    replace_dict = {
        "git_hash": str(git_revision),
        "out_param_fname": "%s" % (out_param_fname),
        "cfg_fname": "%s" % (cfg_fname),
        "met_fname": "%s" % (met_fname),
        "out_fname": "%s" % (out_fname),
        # state
        "age": "12.0",
        # control
        "alloc_model": "allometric",
        "assim_model": "mate",
        "calc_sw_params": "1",  # 0 uses fwp values, 1= derive them
        "deciduous_model": "false",
        "fixed_stem_nc": "1",
        "fixleafnc": "false",
        "grazing": "false",
        "model_optroot": "false",
        "modeljm": "2",
        "nuptake_model": "2",
        "output_ascii": str(ascii),
        "passiveconst": "false",
        "print_options": "daily",
        "ps_pathway": "c3",
        "respiration_model": "fixed",
        "strfloat": "0",
        "trans_model": "1",
        "use_eff_nc": "0",
        "use_leuning": "0",
        "water_stress": "true",
        "sw_stress_model": "1",  # Landsberg
    }
    ad.adjust_param_file(cfg_fname, replace_dict)

    # --- RUN THE MODEL --- #
    G = model.Gday(cfg_fname)
    G.run_sim()

    # translate output to NCEAS style output

    # add this directory to python search path so we can find the scripts!
    sys.path.append("scripts")
    import translate_GDAY_output_to_NCEAS_format as tr

    if ascii:
        tr.translate_output(out_fname, met_fname, binary=False)
    else:
        tr.translate_output(out_fname, met_fname, binary=True)
Beispiel #6
0
def main(experiment_id, site, treatment, ascii=True):

    # --- FILE PATHS, DIR NAMES ETC --- #
    #base_dir = os.getcwd()
    param_dir = "params"
    met_dir = "met_data"
    run_dir = "outputs"

    # --- CHANGE PARAM VALUES ON THE FLY --- #
    itag = "%s_%s_model_youngforest_%s" % (experiment_id, site, treatment)
    otag = "%s_%s_model_simulation_%s" % (experiment_id, site, treatment)
    mtag = "%s_met_data_%s_co2.csv" % (site, treatment)
    out_fn = "D1GDAY%s%s" + (".csv" if ascii else ".bin")
    #import pdb; pdb.set_trace()
    out_fn = out_fn % (site, treatment.upper())

    out_param_fname = os.path.join(param_dir, otag + ".cfg")
    cfg_fname = os.path.join(param_dir, itag + ".cfg")
    met_fname = os.path.join(met_dir, mtag)
    out_fname = os.path.join(run_dir, out_fn)

    replace_dict = {
        "git_hash": str(git_revision),
        "out_param_fname": "%s" % (out_param_fname),
        "cfg_fname": "%s" % (cfg_fname),
        "met_fname": "%s" % (met_fname),
        "out_fname": "%s" % (out_fname),

        # state
        "age": "12.0",

        # control
        "alloc_model": "allometric",
        "assim_model": "mate",
        "calc_sw_params": "1",  #0 uses fwp values, 1= derive them
        "deciduous_model": "false",
        "fixed_stem_nc": "1",
        "fixleafnc": "false",
        "grazing": "false",
        "model_optroot": "false",
        "modeljm": "2",
        "nuptake_model": "2",
        "output_ascii": str(ascii),
        "passiveconst": "false",
        "print_options": "daily",
        "ps_pathway": "c3",
        "respiration_model": "fixed",
        "strfloat": "0",
        "trans_model": "1",
        "use_eff_nc": "0",
        "use_leuning": "0",
        "water_stress": "true",
        "sw_stress_model": "1",  # Landsberg
    }
    ad.adjust_param_file(cfg_fname, replace_dict)

    # --- RUN THE MODEL --- #
    G = model.Gday(cfg_fname)
    G.run_sim()

    # translate output to NCEAS style output

    # add this directory to python search path so we can find the scripts!
    sys.path.append("scripts")
    import translate_GDAY_output_to_NCEAS_format as tr
    if ascii:
        tr.translate_output(out_fname, met_fname, binary=False)
    else:
        tr.translate_output(out_fname, met_fname, binary=True)
def main(experiment_id, site, SPIN_UP=True, POST_INDUST=True, SPIN_UP_SIMS=True):
    base_dir = os.path.dirname(os.getcwd())
    
    # dir names
    base_param_name = "base_start"
    base_dir = os.path.dirname(os.getcwd())
    base_param_dir = "/Users/mq42056055/Documents/gdayFresh/example/params"
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "met_data")
    run_dir = os.path.join(base_dir, "outputs")
    
    
    if SPIN_UP == True:
    
        # copy base files to make two new experiment files
        shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"),                
                    os.path.join(param_dir, "%s_%s_model_spinup.cfg" % \
                    (experiment_id, site)))
        
        # Run model to equilibrium assuming forest, growing C pools from effectively
        # zero
        itag = "%s_%s_model_spinup" % (experiment_id, site)
        otag = "%s_%s_model_spunup" % (experiment_id, site)
        mtag = "%s_met_data_equilibrium_50_yrs.csv" % (site)
        out_fn = itag + "_equilib.out" 
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        
        replace_dict = { 
                         # git stuff
                         "git_hash": str(git_revision),
                     
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
                         
                         # state - default C:N 25.
                         "age": "0.0",
                         "canht": "17.0", # Canopy height increased from 16m in 2001 to 18m in 2004 at Duke
                         "activesoil": "0.001",
                         "activesoiln": "0.00004",
                         "age": "0.0",
                         "branch": "0.001",
                         "branchn": "0.00004",
                         "cstore": "0.001",
                         "inorgn": "0.00004",
                         "metabsoil": "0.0",
                         "metabsoiln": "0.0",
                         "metabsurf": "0.0",
                         "metabsurfn": "0.0",
                         "nstore": "0.00004",
                         "passivesoil": "0.001",
                         "passivesoiln": "0.0004",
                         "prev_sma": "1.0",
                         "root": "0.001",
                         "root_depth": "-9999.9",
                         "rootn": "0.00004",
                         "sapwood": "0.001",
                         "shoot": "0.001",
                         "shootn": "0.00004",
                         "slowsoil": "0.001",
                         "slowsoiln": "0.00004",
                         "stem": "0.001",
                         "stemn": "0.00004",
                         "stemnimm": "0.00004",
                         "stemnmob": "0.0",
                         "structsoil": "0.001",
                         "structsoiln": "0.00004",
                         "structsurf": "0.001",
                         "structsurfn": "0.00004",
                         "croot": "0.0",   # don't simulate coarse roots
                         "crootn": "0.0",  # don't simulate coarse roots
                         
                         # parameters
                         "latitude": "35.9",
                         "intercep_frac": "0.15",
                         "max_intercep_lai": "3.0",
                         "albedo": "0.123",   # modis site avg
                         "finesoil": "0.51", # set based on silt+clay fractions of topsoil 0.42+0.09=0.5
                         "slamax": "4.4",     # Protocol [m2 kg-1 DW]
                         "sla": "4.4",        # Protocol [m2 kg-1 DW]
                         "slazero": "4.4",    # Protocol [m2 kg-1 DW]
                         "cfracts": "0.5",
                         "lai_closed": "0.5",  # I am effectively turning this feature off by setting it so low
                         
                         #"c_alloc_fmax": "0.25",   
                         #"c_alloc_fmin": "0.25",
                         #"c_alloc_rmax": "0.05", 
                         #"c_alloc_rmin": "0.05", 
                         #"c_alloc_bmax": "0.2", 
                         #"c_alloc_bmin": "0.2",
                         
                         #"c_alloc_fmax": "0.3",
                         #"c_alloc_fmin": "0.3",
                         #"c_alloc_rmax": "0.3",
                         #"c_alloc_rmin": "0.3",
                         #"c_alloc_bmax": "0.2", 
                         #"c_alloc_bmin": "0.2", 
                         #"c_alloc_cmax": "0.0", # turn off coarse roots!
                         
                         "c_alloc_fmax": "0.35",
                         "c_alloc_fmin": "0.15",
                         "c_alloc_rmax": "0.35",
                         "c_alloc_rmin": "0.05",
                         "c_alloc_bmax": "0.1", 
                         "c_alloc_bmin": "0.1", 
                         "c_alloc_cmax": "0.0", # turn off coarse roots!
                         
                         
                         "fretrans": "0.5",  
                         "rretrans": "0.0",  
                         "bretrans": "0.0",  
                         "wretrans": "0.0",
                         "ncwnewz": "0.003",    
                         "ncwnew": "0.003",     
                         "ncwimmz": "0.003",    
                         "ncwimm": "0.003",     
                         "ncbnewz": "0.003",    
                         "ncbnew": "0.003",     
                         "ncrfac": "0.8",     
                         "ncmaxfyoung": "0.04",
                         "ncmaxfold": "0.04",  
                         "ncmaxr": "0.03",     
                         "retransmob": "0.0", 
                         "fdecay": "0.59988",      # Protocol  [years-1]
                         "fdecaydry": "0.59988",   # Protocol  
                         "rdecay": "0.33333",      # Protocol     
                         "rdecaydry": "0.33333",   # Protocol    
                         "bdecay": "0.02",         # No data, assuming 50 years
                         "wdecay": "0.02",      
                         "crdecay": "0.00",  # turn off coarse roots!
                         "watdecaydry": "0.0", 
                         "watdecaywet": "0.1", 
                         "ligshoot": "0.24",      # Based on White et al. 2000 for ENF    
                         "ligroot": "0.22",       # Based on White et al. 2000 
                         "rateuptake": "3.0",           # set somewhat (very) arbitarly to get an LAI ~ 4.
                         "rateloss": "0.5",
                         "wcapac_root": "96.75",       # [mm] (FC (m3/m-3)-WP (m3/m-3)) * rooting_depth (mm) using derived values and depth from protocol, 750 mm (FC=0.164 - WP=0.035)
                         "wcapac_topsoil": "25.8",     # [mm] (FC (m3/m-3)-WP (m3/m-3)) * rooting_depth (mm) using derived values and depth from protocol, assuming 200 mm top soil following Corbeels 2005a (FC=0.164 - WP=0.035)
                         
                         
                         "ctheta_topsoil": "0.5",      # Derive based on soil type clay_loam
                         "ntheta_topsoil": "5.0",      # Derive based on soil type clay_loam
                         "ctheta_root": "0.4",         # Derive based on soil type clay
                         "ntheta_root": "3.0",         # Derive based on soil type clay
                         "topsoil_type": "clay_loam",
                         "rootsoil_type": "clay",
                         "measurement_temp": "25.0",
                         "dz0v_dh": "0.075", # However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
                         "displace_ratio": "0.78",
                         "g1": "2.74", 
                         
                         
                         
                         #"jmaxna": "60.0",  # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg!
                         #"jmaxnb": "0.0",   # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg!
                         #"vcmaxna": "30.61",# Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg!
                         #"vcmaxnb": "0.0",  # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg!
                         "vcmaxna": "22.29",
                         "vcmaxnb": "8.45", 
                         "jv_slope": "1.86",
                         "jv_intercept": "0.0",
                         
                         
                         
                         "sapturnover": "0.1",
                         "heighto": "4.826",  
                         "htpower": "0.35",   
                         "height0": "5.0",    
                         "height1": "20.0",   
                         "leafsap0": "8000.0",
                         "leafsap1": "3060.0",  # Duke protocol
                         "branch0": "5.61",   
                         "branch1": "0.346",  
                         "targ_sens": "0.5",  
                         "density": "420.0",  
                         
                         
                         # control
                         "adjust_rtslow": "false",  # priming, off
                         "alloc_model": "allometric",
                         "assim_model": "mate",
                         "calc_sw_params": "false",   #false=use fwp values, true=derive them
                         "deciduous_model": "false",
                         "disturbance": "0",
                         "exudation": "false",
                         "fixed_stem_nc": "true",
                         "fixleafnc": "false",
                         "grazing": "false",
                         "gs_model": "medlyn",
                         "model_optroot": "false",
                         "modeljm": "2",
                         "ncycle": "true",
                         "nuptake_model": "2",
                         "passiveconst": "false",
                         "print_options": "end",
                         "ps_pathway": "c3",
                         "respiration_model": "fixed",
                         "strfloat": "0",
                         "sw_stress_model": "1",  # Sands and Landsberg 
                         "trans_model": "1",
                         "use_eff_nc": "0",
                         "use_leuning": "0",
                         "water_stress": "true",
                         
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        G = model.Gday(cfg_fname, spin_up=True)
        G.spin_up_pools()
        
    
    if POST_INDUST == True:
    
        # run for 200 odd years post industrial with increasing co2/ndep
        # we are swapping forest params for grass params now
        # copy spunup base files to make two new experiment files
        shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_spunup_adj.cfg" % (experiment_id, site)))
        
        itag = "%s_%s_model_spunup_adj" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_industrial_to_present_1850_1983.csv" % (site)
        out_fn = itag + "_indust.out" 
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        print cfg_fname
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        
        replace_dict = { 
                         # git stuff
                         "git_hash": str(git_revision),
                         
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
                        
                         # state - default C:N 25.
                         "age": "0.0",
                         "branch": "0.0",
                         "branchn": "0.0",
                         "canht": "0.79",  # Taken default C3grass value from JULES
                         "cstore": "0.001",
                         "nstore": "0.00004",
                         "croot": "0.0",   # don't simulate coarse roots
                         "crootn": "0.0",  # don't simulate coarse roots
                         "root": "0.001",
                         "rootn": "0.00004",
                         "sapwood": "0.0",
                         "shoot": "0.001",
                         "shootn": "0.00004",
                         "stem": "0.0",
                         "stemn": "0.0",
                         "stemnimm": "0.0",
                         "stemnmob": "0.0",
                         "nepsum": "0.0",
                         "nppsum": "0.0",
                         
                         # parameters
                         "ligshoot": "0.09",  # Smith et al. 2000, GRASS
                         "ligroot": "0.22",   # Smith et al. 2000
                         "age": "1.0",
                         "slamax": "6.0",
                         "sla": "6.0",
                         "slazero": "6.0",
                         "cfracts": "0.5",
                         "lai_closed": "0.5",  # I am effectively turning this feature off by setting it so low
                         "c_alloc_fmax": "0.8",   
                         "c_alloc_fmin": "0.2",
                         "c_alloc_rmax": "0.8", 
                         "c_alloc_rmin": "0.2", 
                         "c_alloc_bmax": "0.0", 
                         "c_alloc_bmin": "0.0",
                         "c_alloc_cmax": "0.0", # turn off coarse roots!
                         "fretrans": "0.4",  
                         "rretrans": "0.0",  
                         "bretrans": "0.0",  
                         "wretrans": "0.0",
                         "ncwnewz": "0.0",    
                         "ncwnew": "0.0",     
                         "ncwimmz": "0.0",    
                         "ncwimm": "0.0",     
                         "ncbnewz": "0.0",    
                         "ncbnew": "0.0",     
                         "ncrfac": "0.7",     
                         "ncmaxfyoung": "0.035",
                         "ncmaxfold": "0.035",  
                         "ncmaxr": "0.0287",     
                         "retransmob": "0.0", 
                         "fdecay": "1.0",     
                         "fdecaydry": "1.0",   
                         "rdecay": "1.0",      
                         "rdecaydry": "1.0",   
                         "bdecay": "0.0",      
                         "wdecay": "0.0",      
                         "watdecaydry": "0.0", 
                         "watdecaywet": "0.1", 
                         "crdecay": "0.00",  # turn off coarse roots!
                         
                         
                         "dz0v_dh": "0.10", # Taken default C3grass value from JULES
                         "displace_ratio": "0.64", #Jones 1992, pg. 67.
                         "z0h_z0m": "1.0",         # Assume z0m = z0h, probably a big assumption [as z0h often < z0m.], see comment in code!! 
                         
                         
                         "jmaxna": "62.0",  # assuming j = v * 2
                         "jmaxnb": "0.0",   # assuming no intercept
                         "vcmaxna": "31.0",   # C3 grasses - CLM4 tech doc, table 8.2, Oleson et al 2010, page 176
                         "vcmaxnb": "0.0",  # assuming no intercept
                         
                         # control
                         "adjust_rtslow": "false",  # priming, off
                         "alloc_model": "grasses",
                         "assim_model": "mate",
                         "calc_sw_params": "false",   #false=use fwp values, true=derive them
                         "deciduous_model": "false",
                         "disturbance": "0",
                         "exudation": "false",
                         "fixed_stem_nc": "true",
                         "fixleafnc": "false",
                         "grazing": "false",
                         "gs_model": "medlyn",
                         "model_optroot": "false",
                         "modeljm": "1",
                         "nuptake_model": "2",
                         "ncycle": "true",
                         "passiveconst": "false",
                         "print_options": "end",
                         "ps_pathway": "c3",
                         "respiration_model": "fixed",
                         "strfloat": "0",
                         "sw_stress_model": "1",  # Sands and Landsberg 
                         "trans_model": "1",
                         "use_eff_nc": "0",
                         "use_leuning": "0",
                         "water_stress": "true",
                         
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        G = model.Gday(cfg_fname)
        G.run_sim()
   

    if SPIN_UP_SIMS:
    
        #
        ## Equilib
        #
    
        # copy spunup base files to make two new experiment files
        shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_spunup_trace.cfg" % (experiment_id, site)))
    
        itag = "%s_%s_model_spunup_trace" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_preindust_traceability_equilib.csv" % (site)
        out_fn = "D1GDAY%sSU280.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = { 
                         # git stuff
                         "git_hash": str(git_revision),
                     
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
                         
                         "print_options": "daily",
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        G = model.Gday(cfg_fname)
        G.run_sim()
    
        # translate output to NCEAS style output

        # add this directory to python search path so we can find the scripts!
        sys.path.append(os.path.join(base_dir, "scripts"))
        import translate_GDAY_output_to_NCEAS_format as tr
        tr.translate_output(out_fname, met_fname)
    
    
        #
        ## Equilib - amb
        #
    
        # copy spunup base files to make two new experiment files
        shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_spunup_trace.cfg" % (experiment_id, site)))
    
        itag = "%s_%s_model_spunup_trace" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_amb_traceability_equilib.csv" % (site)
        out_fn = "D1GDAY%sSUAMB.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = { 
                         # git stuff
                         "git_hash": str(git_revision),
                         
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
                     
                         "print_options": "daily",
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        G = model.Gday(cfg_fname)
        G.run_sim()
    
        # translate output to NCEAS style output

        # add this directory to python search path so we can find the scripts!
        sys.path.append(os.path.join(base_dir, "scripts"))
        import translate_GDAY_output_to_NCEAS_format as tr
        tr.translate_output(out_fname, met_fname)
    
        #
        ## Equilib - ele
        #
    
        # copy spunup base files to make two new experiment files
        shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)),
                    os.path.join(param_dir, "%s_%s_model_spunup_trace.cfg" % (experiment_id, site)))
    
        itag = "%s_%s_model_spunup_trace" % (experiment_id, site)
        otag = "%s_%s_model_indust" % (experiment_id, site)
        mtag = "%s_met_data_ele_traceability_equilib.csv" % (site)
        out_fn = "D1GDAY%sSUELE.csv" % (site)
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = { 
                         # git stuff
                         "git_hash": str(git_revision),
                         
                         # files
                         "out_param_fname": "%s" % (out_param_fname),
                         "cfg_fname": "%s" % (cfg_fname),
                         "met_fname": "%s" % (met_fname),
                         "out_fname": "%s" % (out_fname),
                     
                         "print_options": "daily",
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        G = model.Gday(cfg_fname)
        G.run_sim()
    
        # translate output to NCEAS style output

        # add this directory to python search path so we can find the scripts!
        sys.path.append(os.path.join(base_dir, "scripts"))
        import translate_GDAY_output_to_NCEAS_format as tr
        tr.translate_output(out_fname, met_fname)
Beispiel #8
0
def main(experiment_id, GROW_FOREST=False, RUN_SIM=True):
    
    # dir names
    base_dir = "/Users/mdekauwe/src/python/pygday/example/"
    param_dir = os.path.join(base_dir, "params")
    met_dir = os.path.join(base_dir, "forcing")
    run_dir = os.path.join(base_dir, "runs")
    
    if GROW_FOREST == True:
        # Grow forest from 1984 to start of FACE experiment
        # we are swapping grass params for forest params now
        
        
        itag = experiment_id + "_example"
        otag = experiment_id + "_example_sim"
        mtag = "met_data.gin"
        out_fn = "EXAMPLE.csv"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        # copy base files to make two new experiment files
        shutil.copy(os.path.join(cfg_fname),                
                    os.path.join(param_dir, itag + "_run" +  ".cfg"))
        cfg_fname = os.path.join(param_dir, itag + "_run" +  ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = { 
                         "out_param_fname": '"%s"' % (out_param_fname),
                         "cfg_fname": '"%s"' % (cfg_fname),
                         "met_fname": '"%s"' % (met_fname),
                         "out_fname": '"%s"' % (out_fname),
                         "age": "0.0",
                         "ageold": "1000",
                         "print_options": "1",
                         "albedo": "0.123", # modis site avg
                         "finesoil": "0.5", 
                         "n_crit": "0.04",
                         "slamax": "4.6",  #Drake, 2010, PCE, 33, 1756-1766, fig5
                         "slainit": "4.6", #Drake, 2010, PCE, 33, 1756-1766, fig5
                         "slazero": "4.6", #Drake, 2010, PCE, 33, 1756-1766, fig5
                         "cfracts": "0.5",
                         "lai_cover": "0.5",
                         "callocf": "0.25",   
                         "callocfz": "0.25",
                         "callocrx": "0.0",  
                         "callocr": "0.05", 
                         "callocrz": "0.05", 
                         "callocb": "0.2", 
                         "callocbz": "0.2",
                         "fretrans": "0.5",  
                         "rretrans": "0.0",  
                         "bretrans": "0.0",  
                         "wretrans": "0.0",
                         "ncwnewz": "0.003",    
                         "ncwnew": "0.003",     
                         "ncwimmz": "0.003",    
                         "ncwimm": "0.003",     
                         "ncbnewz": "0.003",    
                         "ncbnew": "0.003",     
                         "ncrfac": "0.8",     
                         "ncmaxfyoung": "0.04",
                         "ncmaxfold": "0.04",  
                         "ncmaxr": "0.03",     
                         "retransmob": "0.0", 
                         "fdecay": "0.63",   # 19 mth turnover * 1/30, McCarthy, 2007, GCB, 13, 2479-2497  
                         "fdecaydry": "0.63", # 19 mth turnover * 1/30, McCarthy, 2007, GCB, 13, 2479-2497 
                         "rdecay": "0.63",      
                         "rdecaydry": "0.63",   
                         "bdecay": "0.02",      
                         "wdecay": "0.02",      
                         "watdecaydry": "0.0", 
                         "watdecaywet": "0.1", 
                         "ligshoot": "0.25",    
                         "ligroot": "0.25",     
                         "brabove": "0.5",     
                         "branch": "0.01",
                         "shoot": "0.01",
                         "root": "0.01",
                         "stem": "0.01",
                         "metabsurf": "0.0",
                         #"metabsoil": "0.0",
                         "metabsurfn": "0.0",
                         #"metabsoiln": "0.0",
                         "branchn": "0.001",
                         "shootn": "0.001",
                         "rootn": "0.001",
                         "stemn": "2E-03",
                         "stemnimm": "0.001",
                         "stemnmob": "0.001",
                         "wcapac_root": "67.387",      # [mm] (FC-WP)*rooting_depth using derived values and depth from Oren et al 1998 
                         "wcapac_topsoil": "6.045",    # [mm] (FC-WP)*rooting_depth using derived values and depth from Oren et al 1998
                         "fwpmax_tsoil": "0.52",      # this is the saturation point so this is wrong, derive value
                         "fwpmin_tsoil": "0.2",
                         "fwpmax_root": "0.52",       # this is the saturation point so this is wrong, derive value
                         "fwpmin_root": "0.2",
                         "topsoil_type": '"clay_loam"',
                         "rootsoil_type": '"clay"',
                         "calc_sw_params": "1",   #0 uses fwp values, 1= derive them
                         "co2_conc": "0",
                         "trans_model": "1",
                         "rateuptake": "5.7", 
                         "rateloss": "0.5",
                         "g1": "2.74", # used to be 4.8
                         "deciduous_model": "0",
                         "canht": "17.0",          # Canopy height increased from 16m in 2001 to 18m in 2004 at Duke
                         "dz0v_dh": "0.075",       # However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17
                         "displace_ratio": "0.78",
                         "z0h_z0m": "1.0",         # Assume z0m = z0h, probably a big assumption [as z0h often < z0m.], see comment in code!! 
                         "callocrx": "0.0",
                         "vxfix": "5.0e-9", # N fixation per unit rhizodeposition 5g/1000g -> tonnes 
                         "modeljm": "1",
                         "jmaxna": "60.0",  # Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "jmaxnb": "0.0",   # Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "vcmaxna": "30.61",# Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "vcmaxnb": "0.0",  # Original values Belinda had, plus largely match scatter plot fig 7, pg 235 Ellsworth 2011
                         "model_optroot": "0",
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        #print cfg_fname
        G = model.Gday(cfg_fname)
        G.run_sim()
    
    if RUN_SIM == True:
        # Run Duke simulation 
        itag = experiment_id + "_example"
        otag = experiment_id + "_example_sim"
        mtag = "met_data.gin"
        out_fn = "EXAMPLE.csv"
        out_param_fname = os.path.join(param_dir, otag + ".cfg")
        cfg_fname = os.path.join(param_dir, itag + ".cfg")
        met_fname = os.path.join(met_dir, mtag)
        out_fname = os.path.join(run_dir, out_fn)
        replace_dict = { 
                         "out_param_fname": '"%s"' % (out_param_fname),
                         "cfg_fname": '"%s"' % (cfg_fname),
                         "met_fname": '"%s"' % (met_fname),
                         "out_fname": '"%s"' % (out_fname),
                         "age": "12.0",
                         "print_options": "0",
                         "co2_conc": "0",
                         "water_stress": "1",
                         "model_optroot": "0",
                        }
        ad.adjust_param_file(cfg_fname, replace_dict)
        
        
        G = model.Gday(cfg_fname)
        G.run_sim()