def extract(my_path_folder,file, my_start_month, my_start_day, my_end_month, my_end_day): my_extraction=DaisyDlf(my_path_folder+'\\'+'%s.dlf' %file) my_extraction=my_extraction.Data years=np.unique([my_extraction.index[i].year for i in range(len(my_extraction.index))]) my_extraction['Date']=my_extraction.index my_extraction.index=np.arange(0,len(my_extraction)) my_start, my_end = [], [] for i in range(len(years)-1): my_start.append(my_extraction['Date'][my_extraction['Date'] == datetime.strptime('%0d-%02d-%02d 00:00:00'%(years[i+1], my_start_month, my_start_day), "%Y-%m-%d %H:%M:%S")].index[0]) my_end.append(my_extraction['Date'][my_extraction['Date'] == datetime.strptime('%0d-%02d-%02d 00:00:00'%(years[i+1], my_end_month, my_end_day), "%Y-%m-%d %H:%M:%S")].index[0]) return my_extraction, my_start, my_end
# find simulated data in corresponding folder for my_start_year, folder in enumerate( sensitivity_analysis['%d' % threshold + '_' + '%d' % space]): print('extraction from folder nb:', my_start_year) # store the pesticide outputs from Daisy field_chemicals = defaultdict() for chem in chemicals: field_chemicals[chem] = DaisyDlf( path_folder + '\\' + folder + '\\' + '%s-%s_%s_field_%s.dlf' % (prefix, depth, col, chem)).Data field_chemicals[chem]['Date'] = field_chemicals[ chem].index field_chemicals[chem].index = np.arange( 0, len(field_chemicals[chem])) # use the harvest file to select find starting and ending # index of 3-month monitoring period each year harvest = DaisyDlf(path_folder + '\\' + folder + '\\' + '%s-harvest.dlf' % prefix) harvest = harvest.Data harvest['Date'] = harvest.index harvest.index = np.arange(0, len(harvest)) start_harvest = (np.where( harvest['Date'] == datetime.strptime( '%d-%02d-%02d 00:00:00' % (my_start_dates[my_start_year], 9, 25), "%Y-%m-%d %H:%M:%S"))[0][0]) # store the starting and ending index every year, # and corresponding water outputs