def get_jid(run_type): """ Generate job ID and send inputs to JSON-RPC model server """ all_dic = { # "run_type" : run_type, # "chemical_name" : chemical_name, # "koc" : koc, # "soil_metabolism_hl" : soil_metabolism_hl, # "crop" : crop, # "crop_number" : crop_number, # "noa" : noa, # "app_method" : app_method, # "application_rate" : application_rate, # "refine" : refine, # "refine_time_window" : refine_time_window, # "refine_percent_applied" : refine_percent_applied, # "region" : region, # "sim_type" : sim_type, # "sim_date_start" : sim_date_start, # "sim_date_end" : sim_date_end, # "sim_date_1stapp" : sim_date_1stapp, # "output_type" : output_type, # "output_tox" : output_tox, # "output_tox_value" : output_tox_value, # "output_format" : output_format, } data = json.dumps(all_dic) logger.info(data) jid = rest_funcs.gen_jid() url=url_part1 + '/sam/' + jid response = requests.post(url=url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] return(jid, output_val)
def get_jid(wat_hl,wat_t,ben_hl,ben_t,unf_hl,unf_t,aqu_hl,aqu_t,hyd_hl,mw,vp,sol,koc,hea_h,hea_r_t, noa,dd_out,mm_out,ma_out,sr_out,weather,wea_l,nof,date_f1,nod_out,fl_out,wl_out,ml_out,to_out, zero_height_ref,days_zero_full,days_zero_removal,max_frac_cov,mas_tras_cof,leak,ref_d,ben_d, ben_por,dry_bkd,foc_wat,foc_ben,ss,wat_c_doc,chl,dfac,q10,area_app): all_dic = {"wat_hl" : wat_hl, "wat_t" : wat_t, "ben_hl" : ben_hl, "ben_t" : ben_t, "unf_hl" : unf_hl, "unf_t" : unf_t, "aqu_hl" : aqu_hl, "aqu_t" : aqu_t, "hyd_hl" : hyd_hl, "mw" : mw, "vp" : vp, "sol" : sol, "koc" : koc, "hea_h" : hea_h, "hea_r_t" : hea_r_t, "noa" : noa, "dd_out" : dd_out, "mm_out" : mm_out, "ma_out" : ma_out, "sr_out" : sr_out, "weather" : weather, "wea_l" : wea_l, "nof" : nof, "date_f1" : date_f1, "nod_out" : nod_out, "fl_out" : fl_out, "wl_out" : wl_out, "ml_out" : ml_out, "to_out" : to_out, "zero_height_ref" : zero_height_ref, "days_zero_full" : days_zero_full, "days_zero_removal" : days_zero_removal, "max_frac_cov" : max_frac_cov, "mas_tras_cof" : mas_tras_cof, "leak" : leak, "ref_d" : ref_d, "ben_d" : ben_d, "ben_por" : ben_por, "dry_bkd" : dry_bkd, "foc_wat" : foc_wat, "foc_ben" : foc_ben, "ss" : ss, "wat_c_doc" : wat_c_doc, "chl" : chl, "dfac" : dfac, "q10" : q10, "area_app" : area_app} data=json.dumps(all_dic) jid=rest_funcs.gen_jid() url=url_part1 + '/pfam/' + jid # response_val = urlfetch.fetch(url=url, payload=data, method=urlfetch.POST, headers=http_headers, deadline=60) response = requests.post(url=url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] return(jid, output_val)
def __init__(self, set_variables=True,run_methods=True,run_type='single',dose_response=1,lc50=1,threshold=1,vars_dict=None): self.set_default_variables() self.jid = rest_funcs.gen_jid() if set_variables: if vars_dict != None: self.__dict__.update(vars_dict) else: self.set_variables(run_type,dose_response,lc50,threshold)
def __init__(self, set_variables=True,run_methods=True,run_type = "single",chemical_name='', b_species='', m_species='', bw_quail=1, bw_duck=1, bwb_other=1, bw_rat=1, bwm_other=1, sol=1, ld50_a=1, ld50_m=1, aw_bird=1, mineau=1, aw_mamm=1, noaec_d=1, noaec_q=1, noaec_o=1, Species_of_the_bird_NOAEC_CHOICES=1, noael=1,vars_dict=None): self.set_default_variables() self.jid = rest_funcs.gen_jid() if set_variables: if vars_dict != None: self.__dict__.update(vars_dict) else: self.set_variables(run_type, chemical_name, b_species, m_species, bw_quail, bw_duck, bwb_other, bw_rat, bwm_other, sol, ld50_a, ld50_m, aw_bird, mineau, aw_mamm, noaec_d, noaec_q, noaec_o, Species_of_the_bird_NOAEC_CHOICES, noael)
def set_variables(self, run_type, chemical_name, b_species, m_species, bw_quail, bw_duck, bwb_other, bw_rat, bwm_other, sol, ld50_a, ld50_m, aw_bird, mineau, aw_mamm, noaec_d, noaec_q, noaec_o, Species_of_the_bird_NOAEC_CHOICES, noael): self.run_type = run_type self.chemical_name = chemical_name self.bw_quail = bw_quail self.bw_duck = bw_duck self.bwb_other = bwb_other self.bw_rat = bw_rat self.bwm_other = bwm_other self.b_species = b_species self.m_species = m_species if b_species =='178': self.bw_bird = self.bw_quail elif b_species =='1580': self.bw_bird = self.bw_duck else: self.bw_bird = self.bwb_other if m_species =='350': self.bw_mamm = self.bw_rat else: self.bw_mamm = self.bwm_other self.sol = sol self.ld50_a = ld50_a self.ld50_m = ld50_m self.aw_bird = aw_bird self.mineau = mineau self.aw_mamm = aw_mamm self.noaec_d = noaec_d self.noaec_q = noaec_q self.noaec_o = noaec_o if Species_of_the_bird_NOAEC_CHOICES == '1': self.noaec = self.noaec_q elif Species_of_the_bird_NOAEC_CHOICES == '2': self.noaec = self.noaec_d elif Species_of_the_bird_NOAEC_CHOICES == '3': self.noaec = self.noaec_o # else: # try: # self.noaec = noaec # except ValueError: # raise ValueError\ # ('self.noaec=%g is a non-physical value.' % self.aw_bird) self.noael = noael all_dic = {"chemical_name":self.chemical_name, "bw_bird":self.bw_bird, "bw_quail":self.bw_quail, "bw_duck":self.bw_duck, "bwb_other":self.bwb_other, "bw_rat":self.bw_rat, "bwm_other":self.bwm_other, "b_species":self.b_species, "m_species":self.m_species, "bw_mamm":self.bw_mamm, "sol":self.sol, "ld50_a":self.ld50_a, "ld50_m":self.ld50_m, "aw_bird":self.aw_bird, "mineau":self.mineau, "aw_mamm":self.aw_mamm, "noaec":self.noaec, "noael":self.noael} data = json.dumps(all_dic) self.jid = rest_funcs.gen_jid() url=url_part1 + '/insect/' + self.jid # response = urlfetch.fetch(url=url, payload=data, method=urlfetch.POST, headers=http_headers, deadline=60) response = requests.post(url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] for key, value in output_val.items(): setattr(self, key, value)
def __init__( self, set_variables=True, run_methods=True, run_type="single", k_ow=1, l_f_e=1, c_s=1, k_d=1, p_s=1, c_w=1, m_w=1, p_e=1, vars_dict=None, ): self.set_default_variables() self.jid = rest_funcs.gen_jid() if set_variables: if vars_dict != None: self.__dict__.update(vars_dict) else: self.run_methods = run_methods self.k_ow = k_ow self.l_f_e = l_f_e self.c_s = c_s self.k_d = k_d self.p_s = p_s # commented input properties are not used in most recent version of EFED model equation # self.c_w = c_w # self.m_w = m_w # self.p_e = p_e # all_dic = {"k_ow":self.k_ow, "l_f_e":self.l_f_e, "c_s":self.c_s, "k_d":self.k_d, "p_s":self.p_s, "c_w":self.c_w, # "m_w":self.m_w, "p_e":self.p_e} all_dic = {"k_ow": self.k_ow, "l_f_e": self.l_f_e, "c_s": self.c_s, "k_d": self.k_d, "p_s": self.p_s} data = json.dumps(all_dic) self.jid = rest_funcs.gen_jid() url = url_part1 + "/earthworm/" + self.jid response = requests.post(url=url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)["result"] for key, value in output_val.items(): setattr(self, key, value)
def __init__(self, set_variables=True,run_methods=True,version_rice="1.0", run_type = "single",chemical_name='', mai=1, dsed=1, a=1, pb=1, dw=1, osed=1, kd=1, vars_dict=None): self.set_default_variables() self.jid = rest_funcs.gen_jid() if set_variables: if vars_dict != None: self.__dict__.update(vars_dict) else: self.set_variables(version_rice,run_type,chemical_name,mai,dsed,a,pb,dw,osed,kd)
def __init__(self, set_variables=True, run_methods=True, run_type='single', drop_size = '', ecosystem_type = '', application_method = '', boom_height = '', orchard_type = '', application_rate=1, distance=1, aquatic_type='', calculation_input='', out_init_avg_dep_foa = 1, out_avg_depo_lbac = 1, out_avg_depo_gha = 1, out_deposition_ngl = 1, out_deposition_mgcm = 1, out_nasae = 1, out_y = 1, out_x = 1, out_express_y = 1, vars_dict=None): self.set_default_variables() self.jid = rest_funcs.gen_jid() if set_variables: if vars_dict != None: self.__dict__.update(vars_dict) else: self.set_variables(run_type, drop_size, ecosystem_type, application_method, boom_height, orchard_type, application_rate, distance, aquatic_type, calculation_input, out_init_avg_dep_foa, out_avg_depo_gha, out_avg_depo_lbac, out_deposition_ngl, out_deposition_mgcm, out_nasae, out_y, out_x, out_express_y)
def set_variables(self, run_type, dose_response, lc50, threshold): self.run_type = run_type self.dose_response = dose_response self.lc50 = lc50 self.threshold = threshold all_dic = {"dose_response":self.dose_response, "lc50":self.lc50, "threshold":self.threshold} data = json.dumps(all_dic) self.jid = rest_funcs.gen_jid() url=url_part1 + '/iec/' + self.jid response = requests.post(url=url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] for key, value in output_val.items(): setattr(self, key, value)
def set_variables(self, run_type, chemical_name, application_rate, column_height, spray_drift_fraction, direct_spray_duration, molecular_weight, vapor_pressure, avian_oral_ld50, body_weight_assessed_bird, body_weight_tested_bird, mineau_scaling_factor, mammal_inhalation_lc50, duration_mammal_inhalation_study, body_weight_assessed_mammal, body_weight_tested_mammal, mammal_oral_ld50): self.run_type = run_type self.chemical_name = chemical_name self.application_rate = application_rate self.column_height = column_height self.spray_drift_fraction = spray_drift_fraction self.direct_spray_duration = direct_spray_duration self.molecular_weight = molecular_weight self.vapor_pressure = vapor_pressure self.avian_oral_ld50 = avian_oral_ld50 self.body_weight_assessed_bird = body_weight_assessed_bird self.body_weight_tested_bird = body_weight_tested_bird self.mineau_scaling_factor = mineau_scaling_factor self.mammal_inhalation_lc50 = mammal_inhalation_lc50 self.duration_mammal_inhalation_study = duration_mammal_inhalation_study self.body_weight_assessed_mammal = body_weight_assessed_mammal self.body_weight_tested_mammal = body_weight_tested_mammal self.mammal_oral_ld50 = mammal_oral_ld50 all_dic = {"run_type": self.run_type, "chemical_name": self.chemical_name, "application_rate": self.application_rate, "column_height": self.column_height, "spray_drift_fraction": self.spray_drift_fraction, "direct_spray_duration": self.direct_spray_duration, "molecular_weight": self.molecular_weight, "vapor_pressure": self.vapor_pressure, "avian_oral_ld50": self.avian_oral_ld50, "body_weight_assessed_bird": self.body_weight_assessed_bird, "body_weight_tested_bird": self.body_weight_tested_bird, "body_weight_tested_bird": self.body_weight_tested_bird, "mineau_scaling_factor": self.mineau_scaling_factor, "mammal_inhalation_lc50": self.mammal_inhalation_lc50, "duration_mammal_inhalation_study": self.duration_mammal_inhalation_study, "body_weight_assessed_mammal": self.body_weight_assessed_mammal, "body_weight_tested_mammal": self.body_weight_tested_mammal, "mammal_oral_ld50": self.mammal_oral_ld50} data = json.dumps(all_dic) self.jid = rest_funcs.gen_jid() url = url_part1 + '/stir/' + self.jid response = requests.post(url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] for key, value in output_val.items(): setattr(self, key, value)
def call_model_server(model, args): """ Sends model input parameters (args) to model backend server and returns the 'response'. 'args' can be type == 'dict' or 'string' (valid JSON string). """ # If 'args' is a Python dictionary, dump it to a JSON string if type(args) == dict: data = json.dumps(args) else: data = args # POST JSON to model server through rest proxy response = rest_funcs.rest_proxy_post(model, data, rest_funcs.gen_jid()) return response
def set_default_variables(self): # inputs self.jid = rest_funcs.gen_jid() self.run_type = 'single' self.chemical_name = '' self.application_rate = 1 self.column_height = 1 self.spray_drift_fraction = 1 self.direct_spray_duration = 1 self.molecular_weight = 1 self.vapor_pressure = 1 self.avian_oral_ld50 = 1 self.body_weight_assessed_bird = 1 self.body_weight_tested_bird = 1 self.mineau_scaling_factor = 1 self.mammal_inhalation_lc50 = 1 self.duration_mammal_inhalation_study = 1 self.body_weight_assessed_mammal = 1 self.body_weight_tested_mammal = 1 self.mammal_oral_ld50 = 1 self.run_type = "single"
def set_variables(self,version_rice,run_type,chemical_name,mai,dsed,a,pb,dw,osed,kd): self.version_rice = version_rice self.run_type = run_type self.chemical_name = chemical_name self.mai = mai self.dsed = dsed self.a = a self.pb = pb self.dw = dw self.osed = osed self.kd = kd all_dic = {"version_rice":self.version_rice,"run_type":self.run_type,"chemical_name":self.chemical_name, "mai":self.mai, "dsed":self.dsed, "a":self.a, "pb":self.pb, "dw":self.dw,"osed":self.osed, "kd":self.kd} data = json.dumps(all_dic) self.jid = rest_funcs.gen_jid() url=url_part1 + '/rice/' + self.jid #response = urlfetch.fetch(url=url, payload=data, method=urlfetch.POST, headers=http_headers, deadline=60) response = requests.post(url=url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] for key, value in output_val.items(): setattr(self, key, value)
def get_jid(chem_name, scenarios, met, farm, mw, sol, koc, vp, aem, anm, aqp, tmper, n_ph, ph_out, hl_out): all_dic = {"chem_name": chem_name, "scenarios": scenarios, "met": met, "farm": farm, "mw": mw, "sol": sol, "koc": koc, "vp": vp, "aem": aem, "anm": anm, "aqp": aqp, "tmper": tmper, "n_ph": n_ph, "ph_out": ph_out, "hl_out": hl_out} data = json.dumps(all_dic) jid=rest_funcs.gen_jid() url=url_part1 + '/exams/' + jid # response_val = urlfetch.fetch(url=url, payload=data, method=urlfetch.POST, headers=http_headers, deadline=60) response = requests.post(url=url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] return(jid, output_val)
def set_variables(self, run_type, drop_size, ecosystem_type, application_method, boom_height, orchard_type, application_rate, distance, aquatic_type, calculation_input, out_init_avg_dep_foa, out_avg_depo_gha, out_avg_depo_lbac, out_deposition_ngl, out_deposition_mgcm, out_nasae, out_y, out_x, out_express_y): self.run_type = run_type self.drop_size = drop_size self.ecosystem_type = ecosystem_type self.application_method = application_method self.boom_height = boom_height self.orchard_type = orchard_type self.application_rate = application_rate self.distance = distance self.aquatic_type = aquatic_type self.calculation_input = calculation_input self.out_init_avg_dep_foa = out_init_avg_dep_foa self.out_avg_depo_gha = out_avg_depo_gha self.out_avg_depo_lbac = out_avg_depo_lbac self.out_deposition_ngl = out_deposition_ngl self.out_deposition_mgcm = out_deposition_mgcm self.out_nasae = out_nasae self.out_y = out_y self.out_x = out_x self.out_express_y = out_express_y all_dic = {"drop_size":drop_size, "ecosystem_type":ecosystem_type, "application_method":application_method, "boom_height":boom_height, "orchard_type":orchard_type, "application_rate":application_rate, "distance":distance, "aquatic_type":aquatic_type, "calculation_input":calculation_input, "out_init_avg_dep_foa":out_init_avg_dep_foa, "out_avg_depo_gha":out_avg_depo_gha, "out_avg_depo_lbac":out_avg_depo_lbac, "out_deposition_ngl":out_deposition_ngl, "out_deposition_mgcm":out_deposition_mgcm, "out_nasae":out_nasae, "out_y":out_y, "out_x":out_x, "out_express_y":out_express_y} data = json.dumps(all_dic) self.jid = rest_funcs.gen_jid() url=url_part1 + '/agdrift/' + self.jid response = requests.post(url=url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] for key, value in output_val.items(): setattr(self, key, value)
def get_jid(run_type, pfac, snowmelt, evapDepth, uslek, uslels, uslep, fieldSize, ireg, slope, hydlength, canopyHoldup, rootDepth, canopyCover, canopyHeight, NumberOfFactors, useYears, USLE_day, USLE_mon, USLE_year, USLE_c, USLE_n, USLE_cn, firstyear, lastyear, dayEmerge_text, monthEmerge_text, dayMature_text, monthMature_text, dayHarvest_text, monthHarvest_text, addYearM, addYearH, irflag, tempflag, fleach, depletion, rateIrrig, albedo, bcTemp, Q10Box, soilTempBox1, numHoriz, SoilProperty_thick, SoilProperty_compartment, SoilProperty_bulkden, SoilProperty_maxcap, SoilProperty_mincap, SoilProperty_oc, SoilProperty_sand, SoilProperty_clay, rDepthBox, rDeclineBox, rBypassBox, eDepthBox, eDeclineBox, appNumber_year, totalApp, SpecifyYears, ApplicationTypes, PestAppyDay, PestAppyMon, Rela_a, app_date_type, DepthIncorp, PestAppyRate, localEff, localSpray, PestDispHarvest, nchem, convert_Foliar1, parentTo3, deg1To2, foliarHalfLifeBox, koc_check, Koc, soilHalfLifeBox, convertSoil1, convert1to3, convert2to3): all_dic = {"pfac": pfac, "snowmelt": snowmelt, "evapDepth": evapDepth, "uslek": uslek, "uslels": uslels, "uslep": uslep, "fieldSize": fieldSize, "ireg": ireg, "slope": slope, "hydlength": hydlength, "canopyHoldup": canopyHoldup, "rootDepth": rootDepth, "canopyCover": canopyCover, "canopyHeight": canopyHeight, "NumberOfFactors": NumberOfFactors, "useYears": useYears, "USLE_day": USLE_day, "USLE_mon": USLE_mon, "USLE_year": USLE_year, "USLE_c": USLE_c, "USLE_n": USLE_n, "USLE_cn": USLE_cn, "firstyear": firstyear, "lastyear": lastyear, "dayEmerge_text": dayEmerge_text, "monthEmerge_text": monthEmerge_text, "dayMature_text": dayMature_text, "monthMature_text": monthMature_text, "dayHarvest_text": dayHarvest_text, "monthHarvest_text": monthHarvest_text, "addYearM": addYearM, "addYearH": addYearH, "irflag": irflag, "tempflag": tempflag, "fleach": fleach, "depletion": depletion, "rateIrrig": rateIrrig, "albedo": albedo, "bcTemp": bcTemp, "Q10Box": Q10Box, "soilTempBox1": soilTempBox1, "numHoriz": numHoriz, "SoilProperty_thick": SoilProperty_thick, "SoilProperty_compartment": SoilProperty_compartment, "SoilProperty_bulkden": SoilProperty_bulkden, "SoilProperty_maxcap": SoilProperty_maxcap, "SoilProperty_mincap": SoilProperty_mincap, "SoilProperty_oc": SoilProperty_oc, "SoilProperty_sand": SoilProperty_sand, "SoilProperty_clay": SoilProperty_clay, "rDepthBox": rDepthBox, "rDeclineBox": rDeclineBox, "rBypassBox": rBypassBox, "eDepthBox": eDepthBox, "eDeclineBox": eDeclineBox, "appNumber_year": appNumber_year, "totalApp": totalApp, "SpecifyYears": SpecifyYears, "ApplicationTypes": ApplicationTypes, "PestAppyDay": PestAppyDay, "PestAppyMon": PestAppyMon, "Rela_a": Rela_a, "app_date_type": app_date_type, "DepthIncorp": DepthIncorp, "PestAppyRate": PestAppyRate, "localEff": localEff, "localSpray": localSpray, "PestDispHarvest": PestDispHarvest, "nchem": nchem, "convert_Foliar1": convert_Foliar1, "parentTo3": parentTo3, "deg1To2": deg1To2, "foliarHalfLifeBox": foliarHalfLifeBox, "koc_check": koc_check, "Koc": Koc, "soilHalfLifeBox": soilHalfLifeBox, "convertSoil1": convertSoil1, "convert1to3": convert1to3, "convert2to3": convert2to3} logger.info(all_dic) data = json.dumps(all_dic) jid = rest_funcs.gen_jid() url=url_part1 + '/przm5/' + jid if run_type == "single" or "qaqc": # response = urlfetch.fetch(url=url, payload=data, method=urlfetch.POST, headers=http_headers, deadline=60) response = requests.post(url=url, data=data, headers=http_headers, timeout=60) output_val = json.loads(response.content)['result'] # jid= json.loads(response.content)['jid'] # print "filepath=", output_val[4] # self.elapsed = (time.clock() - start) return(jid, output_val)