# Name of the data release, set paths drelease = 'FLUXNET2015_a' af_path = '/home/greg/sftp/eddyflux/Ameriflux_files/' + drelease + '/' outpath = '/home/greg/current/NMEG_utils/processed_data/daily_aflx/' + drelease + '/' # Years to load startyr = 2007 endyr = 2016 # Sites to load sites = ['Seg', 'Ses', 'Sen', 'Wjs', 'Mpj', 'Mpg', 'Vcp', 'Vcm'] # Fill a dict with multiyear dataframes for each site in sites hourly = { x : ld.get_multiyr_aflx( 'US-' + x, af_path, gapfilled=True, startyear=startyr, endyear=endyr) for x in sites } # Resample to daily sums with integration daily = { x : tr.resample_30min_aflx( hourly[x], freq='1D', c_fluxes=[ 'GPP', 'RECO', 'FC_F' ], le_flux=[ 'LE_F' ], avg_cols=[ 'TA_F', 'RH_F', 'SW_IN_F', 'RNET_F', 'VPD_F', 'PAR', 'LE_F', 'H_F' ], int_cols=['LE_F', 'H_F' ], sum_cols=['P_F'] , tair_col='TA_F' ) for x in hourly.keys() } # Add ET, PET and put into daily dataframes for i, site in enumerate(sites):
'Lass10 ECB']) fig.add_subplot(2,1,2) plt.plot(site_df_resamp.index, site_df_resamp.RECO_g_int, '-k') plt.plot(site_df_resamp.index, site_df_resamp.Reco_MR2005_g_int, '--r') plt.plot(site_df_resamp.index, site_df_resamp.Reco_GL2010_g_int, '--b') plt.plot(site_df_resamp.index, site_df_resamp.Reco_MR2005_g_int_ecb, ':r') plt.plot(site_df_resamp.index, site_df_resamp.Reco_GL2010_g_int_ecb, ':b') plt.ylabel('Reco') plt.show() return fig for i, site in enumerate( siteNames ): # Get the multi-year ameriflux dataframe site_df = ld.get_multiyr_aflx( site, datapath, gapfilled=True, startyear=startyear, endyear=endyear ) # Create a daily dataframe these are pretty much the defaults site_df_resamp = tr.resample_30min_aflx( site_df, freq='1D', c_fluxes=[ 'GPP', 'RECO', 'FC_F' ], le_flux=['LE_F'], avg_cols=['TA_F', 'RH_F', 'SW_IN_F', 'RNET_F'], sum_cols=['P_F'] , tair_col='TA_F' ) # Get multiyear eddyproc file site_df_MR2005 = ld.get_multiyr_eddyproc( site, datapath + 'eddyproc_out/', GL2010=False, startyear=startyear, endyear=endyear ) # Ensure carbon balance steps (GPP = RE-NEE, add negative values to RE) # Raw GPP (contains negative values) diff = site_df_MR2005.Reco - site_df.FC_F negGPPix = diff<0 site_df_MR2005['GPP_ecb'] = diff
import matplotlib.pyplot as plt import pdb as pdb import datetime as dt # Years to load start = 2007 end = 2015 # Sites to load sites = ['Seg', 'Ses', 'Sen', 'Wjs', 'Mpj', 'Mpg', 'Vcp', 'Vcm'] #sites = ['Mpj','Wjs'] # Load hourly data into multiyear dataframes (1/site) within a dict hourly = { x: ld.get_multiyr_aflx('US-' + x, af_path, gapfilled=True, startyear=start, endyear=end) for x in sites } # Now calculate the hours of C uptake for site in sites: # Add a column with 0.5 for each uptake period (to sum) hourly[site]['hrs_C_uptake'] = 0 test = hourly[site].FC_F < 0 hourly[site].loc[test, 'hrs_C_uptake'] = 0.5 # Turn this into a daily dataset daily = { x: tr.resample_30min_aflx(
datapath = ('/home/greg/sftp/eddyflux/Ameriflux_files/provisional/') fileList = os.listdir(datapath) startyear = 2008 endyear = 2014 # List AF site names in same order siteNames = ['US-Mpj'] for i, site in enumerate(siteNames): # Get the multi-year ameriflux dataframe site_df = ld.get_multiyr_aflx(site, datapath, gapfilled=True, startyear=startyear, endyear=endyear) site_df = site_df[[ 'FC_F', 'FC_F_FLAG', 'TA_F', 'TA_F_FLAG', 'VPD_F', 'VPD_F_FLAG' ]] # Export site_df.to_csv('../processed_data/' + site + '_Cleverly.csv', na_rep='-9999', date_format='%Y%m%d%H%M%S') # Function for plotting fixed and original data #def plotfixed(df, var1): # # Plot filled series over original data