def main(argv): heat_d, h2o_d = get_climate_data() irrigation_d = get_irrigation_data() the_db.query(queries.starch_query) data = the_db.store_result().fetch_row(how=1, maxrows=0) data = [DO.StarchData(d.keys(), d.values()) for d in data] golm_data = CD1.group_by([d for d in data if d.location_id == 4537], 'sub_id') dethl_data = CD1.group_by([d for d in data if d.location_id == 5519], 'sub_id') field_data = [d for d in data if d.location_id in FIELD_TRIALS] jki_gh_data = CD1.group_by([d for d in data if d.location_id == 6019], 'sub_id') jki_sh_data = CD1.group_by([d for d in data if d.location_id == 6020], 'sub_id') jki_gh_results = CD1.compute_starch_rel_ctrl(jki_gh_data, 6019, [CD1.DROUGHT_ID]) jki_sh_results = CD1.compute_starch_rel_ctrl(jki_sh_data, 6020, [CD1.DROUGHT_ID]) golm_results = CD1.compute_starch_rel_ctrl(golm_data, 4537, [CD1.DROUGHT_ID]) dethl_results = CD1.compute_starch_rel_ctrl(dethl_data, 5519, CD1.DETHLINGEN_DROUGHT_IDS) field_results = CD1.compute_starch_rel_field(field_data, FIELD_TRIALS, CD1.DROUGHT_ID) all_results = [(jki_gh_results, 'JKI_CGW'), (jki_sh_results, 'JKI_SHE'), (golm_results, 'MPI_FIELD'), (dethl_results, 'DET_FIELD'), (field_results, 'ALL_FIELD')] """ compiled = {} # compiled.update(golm_results) compiled.update(dethl_results) # compiled.update(field_results) # compiled.update(jki_sh_results) # compiled.update(jki_gh_results) """ for data, name in all_results: print name annotate_compiled_data(data, heat_d, h2o_d, irrigation_d) WT.write_table(data, WT.FIELDS, out=open('STARCH_REL_%s.csv' % name, 'w')) return None """
def main(argv): """ Climate data """ the_db.query(queries.climate_query) climate_data = the_db.store_result().fetch_row(how=1, maxrows=0) climate_data = [DO.ClimateData(d.keys(), d.values()) for d in climate_data] heat_d, h2o_d = CD1.compute_climate_data(climate_data) # print heat_d # return None the_db.query(queries.starch_query) data = the_db.store_result().fetch_row(how=1, maxrows=9999999) data = [DO.StarchData(d.keys(), d.values()) for d in data] golm_data = CD1.group_by([d for d in data if d.location_id == 4537], 'sub_id') dethl_data = CD1.group_by([d for d in data if d.location_id == 5519], 'sub_id') field_data = [d for d in data if d.location_id in FIELD_TRIALS] golm_results = CD1.compute_starch_rel_ctrl(golm_data, 4537, [CD1.DROUGHT_ID]) dethl_results = CD1.compute_starch_rel_ctrl(dethl_data, 5519, CD1.DETHLINGEN_DROUGHT_IDS) field_results = CD1.compute_starch_rel_field(field_data, FIELD_TRIALS, CD1.DROUGHT_ID) # print field_results compiled = {} # compiled.update(golm_results) # compiled.update(dethl_results) compiled.update(field_results) for k, v in sorted(compiled.items()): if isinstance(k, str): continue # print k compiled[k].heat_sum, compiled[k].heat_nmeasures = heat_d[k[0]] compiled[k].limsloc = k[0] compiled[k].precipitation, compiled[k].prec_nmeasures = h2o_d[k[0]] # print v # print heat_d WT.write_table(compiled, WT.FIELDS) return None """
def main(argv): heat_d, h2o_d = CD2.get_climate_data() the_db.query(daisy_query) data = the_db.store_result().fetch_row(how=1, maxrows=0) data = [DO.StarchData(d.keys(), d.values()) for d in data] field_data = [d for d in data if d.location_id in CD2.FIELD_TRIALS] # print field_data field_results = CD1.compute_starch_rel_field(field_data, CD2.FIELD_TRIALS, CD1.DROUGHT_ID) compiled = {} compiled.update(field_results) for k, v in sorted(compiled.items()): if isinstance(k, str): continue compiled[k].heat_sum, compiled[k].heat_nmeasures = heat_d[k[0]] compiled[k].limsloc = k[0] compiled[k].precipitation, compiled[k].prec_nmeasures = h2o_d[k[0]] WT.write_table(compiled, WT.FIELDS) return None