rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if len(mods_changed): | if len(mods_changed) or all_modules: | def start(self): self.logfiles = {} global ports_pool builder_props = self.build.getProperties() if not ports_pool: # Effectively, the range of these ports will limit the number of # simultaneous databases that can be tested min_port = builder_props.getProperty('min_port',8200) max_port = builder_props.getProperty('max... |
(re.compile(r" ValueError\('invalid literal for float\(\): (bob'|10,0'),\)"), | (re.compile(r" ValueError\('invalid literal for float\(\): (bob'|10/0'),\)"), | def test_suite(): import doctest checker = zope.testing.renormalizing.RENormalizing([ (re.compile(r"\[WidgetInputError\('form.summary', 'summary', ValidationError\('A error message'\)\)\]"), r"[<zope.formlib.interfaces.WidgetInputError instance at ...>]"), (re.compile(r"\[WidgetInputError\('summary', u'Summary', None\)... |
def test(): """ test method""" | def googlemaps_key(self): """ returns google maps api key for a website""" | def test(): """ test method""" |
@property | def _search_key(self, property_id): if self.properties is None: return None keys_list = getattr(self.properties, property_id, None) if keys_list is None: return None keys = {} for key in keys_list: url, key = key.split('|') url = url.strip() # remove trailing slashes url = url.strip('/') key = key.strip() keys[url] = k... | |
print ia[0].Subject, tags | def get_implementing_agency_uid(agency, context, tags): sa = '"' + agency +'"' ia = context.portal_catalog( portal_type='ContactOrganization', Title=sa) assert(len(ia)==1) print ia[0].Subject, tags ia[0].getObject().setSubject(tags) ia[0].getObject().reindexObject(idxs=['Subject']) return ia[0].getObject().UID() | |
new.update(creation_date=old.creation_date) if old.effective_date: new.setEffectiveDate(old.effective_date) | new.setCreationDate(old.CreationDate()) if old.getEffectiveDate(): new.setEffectiveDate(old.getEffectiveDate()) | def migrate_metadata(old, new, old_parent, new_parent): new.update(creation_date=old.creation_date) if old.effective_date: new.setEffectiveDate(old.effective_date) else: new.setEffectiveDate(old.creation_date) new.setCreators(old.Creators()) new.setModificationDate(old.creation_date) new.setSubject(old.Subject()) uid =... |
new.setEffectiveDate(old.creation_date) | new.setEffectiveDate(old.CreationDate()) | def migrate_metadata(old, new, old_parent, new_parent): new.update(creation_date=old.creation_date) if old.effective_date: new.setEffectiveDate(old.effective_date) else: new.setEffectiveDate(old.creation_date) new.setCreators(old.Creators()) new.setModificationDate(old.creation_date) new.setSubject(old.Subject()) uid =... |
new.setModificationDate(old.creation_date) | new.setModificationDate(old.ModificationDate()) | def migrate_metadata(old, new, old_parent, new_parent): new.update(creation_date=old.creation_date) if old.effective_date: new.setEffectiveDate(old.effective_date) else: new.setEffectiveDate(old.creation_date) new.setCreators(old.Creators()) new.setModificationDate(old.creation_date) new.setSubject(old.Subject()) uid =... |
old._uncatalogUID(new_parent) | old._uncatalogUID(old_parent) | def migrate_metadata(old, new, old_parent, new_parent): new.update(creation_date=old.creation_date) if old.effective_date: new.setEffectiveDate(old.effective_date) else: new.setEffectiveDate(old.creation_date) new.setCreators(old.Creators()) new.setModificationDate(old.creation_date) new.setSubject(old.Subject()) uid =... |
portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) | self.portal_types.constructContent('Project', new_parent, obj_id) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... |
new.update(title=old.title) | new.update(title=old.Title()) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... |
new.SetCountry(update_countries(old.getCountry())) | new.setCountry(update_countries(old.getCountry())) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... |
new.setGef_project_id(old.getGef_project_id ) | new.setGef_project_id(old.getGef_project_id() ) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... |
new.setLatitude(old.getLeadagency() ) | new.setLatitude(old.getLatitude() ) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... |
pass | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... | |
pass | new.setLeadagency(lauid) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... |
la_obj.setProjectlead(project_uids) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... | |
new.setOther_implementing_agency(auids) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... | |
oia_obj.setProjectimplementing(project_uids) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... | |
migrate_metadata(old, new, old_parent, new_parent) | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... | |
new.manage_pasteObjects(old.manage_cutObjects(child.id)) | pass | def migrate_project(old, old_parent, new_parent, f): new = None if callable(old.id): obj_id = old.id() else: obj_id = old.id portal_types = parent.portal_types portal_types.constructContent('Project', new_parent, obj_id) print old.Title() new = new_parent[obj_id] # set fields new.update(title=old.title) new.setBasin(ol... |
portal_types = parent.portal_types portal_types.constructContent('Project Database', parent, obj_id) | print 'create new project db' self.portal_types.constructContent('Project Database', parent, obj_id) | f.write('def migrate(self):\n') |
new = None | f.write('def migrate(self):\n') | |
migrate_metadata(obj, new, parent, parent) for child in obj.objectValues(): | for child_id in obj.objectIds(): child = obj[child_id] | f.write('def migrate(self):\n') |
if old.getBrefs(): | if old.getBRefs(): | def migrate_organization(old, f): if old.getBrefs(): f.write(' #organization \n') f.write(' obj=uid_tool.lookupObject("' + old.UID() + '")\n') f.write(' if obj:\n') f.write(' obj.setContactpersons([') for person in old.getBRefs(): f.write(' "' + person.UID() + '",') f.write('])\n') |
return self.heb_nom | language = self.REQUEST.get('LANGUAGE', 'en') typeHeb = self.type.getTitle(language) return u"%s - %s - %s" % (typeHeb, self.heb_nom, self.heb_localite) | def Title(self): return self.heb_nom |
tmpf_qc_av = figure(nc_tmpk[i], tmpkQCD[i]) tmpf_qc_sc = figure(nc_tmpk[i], tmpkQCD[i]) dwpf_qc_av = figure(nc_dwpk[i], dwpkQCD[i]) dwpf_qc_sc = figure(nc_dwpk[i], dwpkQCD[i]) | tmpf_qc_av = figure(nc_tmpk[i], tmpkQCD[i,0]) tmpf_qc_sc = figure(nc_tmpk[i], tmpkQCD[i,6]) dwpf_qc_av = figure(nc_dwpk[i], dwpkQCD[i,0]) dwpf_qc_sc = figure(nc_dwpk[i], dwpkQCD[i,6]) | def check(val): if (val > 1000000.): return 'Null' return val |
time.sleep(0.3) | time.sleep(1.3) | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) data = opener.open(url).read() lines = data.split("\n") headers = {} f... |
print "Station %s Begin: %s Obs: %s" % (sid, tbegin.strftime("%Y-%m-%d"), processed) | if tbegin is not None: print "Station %s Begin: %s Obs: %s" % (sid, tbegin.strftime("%Y-%m-%d"), processed) | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) data = opener.open(url).read() lines = data.split("\n") headers = {} f... |
print "USING %s NCVAR %s DIVISOR %s" % (makefp(now), ncvar, divisor) | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ # First possible file we are interested in.... sts = ts + mx.DateTime.RelativeDateTime(hour=1, minute=0) # Last possible file, base 5 ets = ts - mx.DateTime.RelativeDateTime(minutes= (ts.minute%5)) now = ets total = None lts = None lon... | |
rs = mesosite.query("SELECT * from stations WHERE network = '%s'" % ( | rs = mesosite.query("SELECT * from stations WHERE network = '%s' ORDER by id DESC" % ( | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) try: data = opener.open(url).read() except: print "Fail STID: %s NOW: ... |
if len(rs2) == 0: | if len(rs2) == 0 or rs2[0]['min'] is None: | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) try: data = opener.open(url).read() except: print "Fail STID: %s NOW: ... |
for sid in ids: | for j in range(len(ids)): sid = ids[j] | def check(val): if (val > 1000000.): return 'Null' return val |
for station in ['MCW','BRL','AMW','MIW','SPW','OTM','CID','EST','IOW', 'SUX','DBQ','ALO','DSM','DVN','LWD','MLI','OMA','FSD']: | for station in ['OMA', 'MCW','BRL','AMW','MIW','SPW','OTM','CID','EST', 'IOW','SUX','DBQ','ALO','DSM','DVN','LWD','MLI','FSD']: | def runner(station, monthts): """ Parse a month's worth of data please """ # Our final amount of data data = {} # We have two files to worry about page1 = open('data/%s/64050K%s%s%02i.dat' % (station, station, monthts.year, monthts.month), 'r') page2 = open('data/%s/64060K%s%s%02i.dat' % (station, station, monthts.ye... |
nc = netCDF3.Dataset("/mesonet/data/iemre/%s_hourly.nc" % (ts.year,),'a') | nc = netCDF3.Dataset("/mnt/mesonet/data/iemre/%s_hourly.nc" % (ts.year,),'a') | def merge(ts): """ Process an hour's worth of stage4 data into the hourly RE """ fp = "/mesonet/ARCHIVE/data/%s/stage4/ST4.%s.01h.grib" % ( ts.strftime("%Y/%m/%d"), ts.strftime("%Y%m%d%H") ) grib = Nio.open_file(fp, 'r') # Rough subsample, since the whole enchillata is too much lats = numpy.ravel( grib.variables["g5_... |
if not headers.has_key("FullMetar"]: | if not headers.has_key("FullMetar"): | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) try: data = opener.open(url).read() except: print "Fail STID: %s NOW: ... |
tmpf_qc_av, tmpf_qc_sc, dwpf, dwpf_qc_av, \ dwpf_qc_sc, alti, alti_qc_av, alti_qc_sc, \ | tmpf_qc_av, tmpf_qc_sc, dwpf, dwpf_qc_av, dwpf_qc_sc, alti, alti_qc_av, alti_qc_sc, | def check(val): if (val > 1000000.): return 'Null' return val |
and year >= %s and year < %s \ | and year >= %s and year < %s and month > 1 \ | def write(mydb, stationID): import mx.DateTime, constants out = open("reports/%s_%s.txt" % (stationID, _REPORTID), 'w') constants.writeheader(out, stationID) # Load up dict of dates.. cnt = {} for day in range(30,182): cnt[day] = {32: 0.0, 28: 0.0, 26: 0.0, 22: 0.0} cnt_years = {32: 0.0, 28: 0.0, 26: 0.0, 22: 0.0} fo... |
day = '%s'""" % (ts.year, rs[0]['max_tmpf'], rs[0]['min_tmpf'], rs[0]['pday'], station, date) | day = '%s'""" % (ts.year, (rs[0]['max_tmpf'] or 'Null'), (rs[0]['min_tmpf'] or 'Null'), (rs[0]['pday'] or 'Null'), station, date) | def compare_with_summary(ts, row): station = row['station'] date = row['d'] rainfall= row['rainfall'] high = row['high'] low = row['low'] rs = iem.query("""SELECT * from summary_%s WHERE station = '%s' and day = '%s'""" % (ts.year, station, date)).dictresult() # Check to see if we should add an entry into the... |
'_valid' : 'Total up to %s' % (lts.strftime("%d %B %Y %I %p %Z"),), | '_valid' : 'Total up to %s' % ( (lts - mx.DateTime.RelativeDateTime(minutes=1)).strftime("%d %B %Y %I:%M %p %Z"),), | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ sts = ts + mx.DateTime.RelativeDateTime(hour=1) ets = ts + mx.DateTime.RelativeDateTime(hour=1, days=1) interval = mx.DateTime.RelativeDateTime(hours=1) now = sts total = None lts = None while now < ets: fp = "/mesonet/ARCHIVE/data/%s/s... |
for station in ['MCW','BRL','AMW','MIW','SPW','OTM','CID','EST','IOW', | if len(sys.argv) == 3: for station in ['MCW','BRL','AMW','MIW','SPW','OTM','CID','EST','IOW', | def runner(station, monthts): """ Parse a month's worth of data please """ # Our final amount of data data = {} # We have two files to worry about page1 = open('data/%s/64050K%s%s%02i.dat' % (station, station, monthts.year, monthts.month), 'r') page2 = open('data/%s/64060K%s%s%02i.dat' % (station, station, monthts.ye... |
runner(station, mx.DateTime.DateTime(int(sys.argv[1]),int(sys.argv[2]),1)) | runner(station, mx.DateTime.DateTime(int(sys.argv[1]),int(sys.argv[2]),1)) else: test() | def runner(station, monthts): """ Parse a month's worth of data please """ # Our final amount of data data = {} # We have two files to worry about page1 = open('data/%s/64050K%s%s%02i.dat' % (station, station, monthts.year, monthts.month), 'r') page2 = open('data/%s/64060K%s%s%02i.dat' % (station, station, monthts.ye... |
doday(mx.DateTime.DateTime(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3])) | doday(mx.DateTime.DateTime(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]))) | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ sts = ts + mx.DateTime.RelativeDateTime(hour=1) ets = ts + mx.DateTime.RelativeDateTime(hour=0, days=1) interval = mx.DateTime.RelativeDateTime(hours=1) now = sts total = None lts = None while now < ets: fp = "/mesonet/ARCHIVE/data/%s/s... |
ioc.append( obs[stid][ts]["ioc_tmpk"] ) gsd.append( obs[stid][ts]["gsd_tmpk"] ) | if (obs[stid][ts].has_key("gsd_tmpk") and obs[stid][ts].has_key("ioc_tmpk")): ioc.append( obs[stid][ts]["ioc_tmpk"] ) gsd.append( obs[stid][ts]["gsd_tmpk"] ) | def print_summary( obs ): for stid in obs.keys(): cnt = len(obs[stid].keys()) ioc = [] gsd = [] for ts in obs[stid].keys(): ioc.append( obs[stid][ts]["ioc_tmpk"] ) gsd.append( obs[stid][ts]["gsd_tmpk"] ) (a_s,b_s,r,tt,stderr)=stats.linregress(gsd,ioc) print "%s %2i %4.2f" % (stid, cnt, r**2), for k in range(7): ioc = ... |
ioc.append( obs[stid][ts]["ioc_tmpkqcd"][k] ) gsd.append( obs[stid][ts]["gsd_tmpkqcd"][k] ) | if (obs[stid][ts].has_key("gsd_tmpkqcd") and obs[stid][ts].has_key("ioc_tmpkqcd")): ioc.append( obs[stid][ts]["ioc_tmpkqcd"][k] ) gsd.append( obs[stid][ts]["gsd_tmpkqcd"][k] ) | def print_summary( obs ): for stid in obs.keys(): cnt = len(obs[stid].keys()) ioc = [] gsd = [] for ts in obs[stid].keys(): ioc.append( obs[stid][ts]["ioc_tmpk"] ) gsd.append( obs[stid][ts]["gsd_tmpk"] ) (a_s,b_s,r,tt,stderr)=stats.linregress(gsd,ioc) print "%s %2i %4.2f" % (stid, cnt, r**2), for k in range(7): ioc = ... |
from alldata WHERE valid >= '%s' GROUP by station, d, hr) as foo | from alldata WHERE valid >= '%s' and valid < '%s' GROUP by station, d, hr) as foo | def run_month(ts): rs = awos.query("""select station, d, sum(rainfall) as rainfall, max(high) as high, min(low) as low from (SELECT station, date(valid) as d, extract(hour from valid) as hr, max(p01i) as rainfall, max(tmpf) as high, min(tmpf) as low from alldata WHERE valid >= '%s' GROUP by station, d, hr) as foo GROUP... |
ts.strftime("%Y-%m-%d") )).dictresult() | ts.strftime("%Y-%m-%d"), (ts + mx.DateTime.RelativeDateTime(months=1)).strftime("%Y-%m-%d") ) ).dictresult() | def run_month(ts): rs = awos.query("""select station, d, sum(rainfall) as rainfall, max(high) as high, min(low) as low from (SELECT station, date(valid) as d, extract(hour from valid) as hr, max(p01i) as rainfall, max(tmpf) as high, min(tmpf) as low from alldata WHERE valid >= '%s' GROUP by station, d, hr) as foo GROUP... |
sid = rs[i]['station'] | sid = rs[i]['id'] | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) data = opener.open(url).read() lines = data.split("\n") headers = {} f... |
tend = mx.DateTime.strptime(rs2[0]['min'], '%Y-%m-%d') | tend = mx.DateTime.strptime(rs2[0]['min'][:16], '%Y-%m-%d %H:%M') | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) data = opener.open(url).read() lines = data.split("\n") headers = {} f... |
(extract(month from valid) = 12 and extract(day from valid) = 31) | (extract(month from valid) = 12 and extract(day from valid) = 31) or extract(day from valid) = 1 | def recover(): """ Account for a stupid processing error I did with not accounting for obs at the end of the month """ network = sys.argv[1] rs = mesosite.query("SELECT * from stations WHERE network = '%s' ORDER by id DESC" % ( network,)).dictresult() for i in range(len(rs)): sid = rs[i]['id'] # Delete all obs from the... |
offset = int((ts - (ts + mx.DateTime.RelativeDateTime(month=1,day=1))).hours) | offset = int((ts - (ts + mx.DateTime.RelativeDateTime(month=1,day=1,hour=0))).hours) | def fix_hourly(ts): """ Fix the hourly precipitation values, just hard code the stupid IEMRE value """ nc = netCDF3.Dataset("/mnt/mesonet/data/iemre/%s_hourly.nc" % (ts.year,),'r') p01m = nc.variables['p01m'] offset = int((ts - (ts + mx.DateTime.RelativeDateTime(month=1,day=1))).hours) # Find ISUAG Data rs = isuag.que... |
ts = mx.DateTime.gmt() + mx.DateTime.RelativeDateTime(days=-1,hour=0,minute=0) | ts = mx.DateTime.gmt() + mx.DateTime.RelativeDateTime(days=-1,hour=0,minute=0,second=0) | def fix_hourly(ts): """ Fix the hourly precipitation values, just hard code the stupid IEMRE value """ nc = netCDF3.Dataset("/mnt/mesonet/data/iemre/%s_hourly.nc" % (ts.year,),'r') p01m = nc.variables['p01m'] offset = int((ts - (ts + mx.DateTime.RelativeDateTime(month=1,day=1))).hours) # Find ISUAG Data rs = isuag.que... |
%s.000000 %s.0000""" % (gts.strftime("%Y%m%d%H%M"), west, north)) | %s %s""" % (gts.strftime("%Y%m%d%H%M"), west, north)) | def doit(gts): """ Actually generate a PNG file from the 8 NMQ tiles """ szx = 7000 szy = 3500 west = -130. north = 55. # Create the image data imgdata = numpy.zeros( (szy, szx), 'u1') # Loop over tiles for tile in range(1,9): fp = make_fp(tile, gts) if not os.path.isfile(fp): print "Missing", fp continue nc = netCDF3.... |
if (val > 1000000.): | if val > 1000000.: | def check(val): if (val > 1000000.): return 'Null' return val |
iemaccess.query(sql) | sql = sql.replace("--", "Null").replace("nan", "Null") try: iemaccess.query(sql) except: print sql | def check(val): if (val > 1000000.): return 'Null' return val |
if tbegin is not None: print "Station %s Begin: %s Obs: %s" % (sid, tbegin.strftime("%Y-%m-%d"), processed) recover() | if tbegin is not None: print "Station %s Begin: %s Obs: %s" % (sid, tbegin.strftime("%Y-%m-%d"), processed) normal() | def normal(): network = sys.argv[1] # 1. Query for a list of stations to iterate over rs = mesosite.query("SELECT * from stations WHERE network = '%s' ORDER by id DESC" % ( network,)).dictresult() for i in range(len(rs)): sid = rs[i]['id'] # 2. Look in the database for earliest ob with METAR rs2 = asos.query("""SELECT ... |
os.system( thumbpqstr ) | cmd = "/home/ldm/bin/pqinsert -p '%s' %s.png" % (thumbpqstr, tmpfp) os.system( cmd ) | def postprocess(tmpfp, pqstr, rotate="", thumb=False, thumbpqstr=""): """ Helper to postprocess the plot """ if not os.path.isfile("%s.ps" % (tmpfp,)): print "File %s.ps is missing!" % (tmpfp,) return # Step 1. Convert to PNG cmd = "convert %s -trim -border 5 -bordercolor '#fff' -resize 900x700 -density 120 -depth 8 -c... |
total[10:20,10:20] = 10.0 | total[1350,1610] = 100.0 total[1410,1675] = 15. | def doit(ts, hours): """ Create a plot of precipitation stage4 estimates for some day """ # Mod the minute down remain = ts.minute % 5 ts -= mx.DateTime.RelativeDateTime(minutes=(ts.minute%5)) lons = numpy.arange(-110., -89.99, 0.01) lats = numpy.arange(55.0, 39.99, -0.01) limit = 20 while not os.path.isfile(make_fp(... |
rs[0]['high'] != high or rs[0]['low'] != low): | rs[0]['max_tmpf'] != high or rs[0]['min_tmpf'] != low): | def compare_with_summary(ts, row): station = row['station'] date = row['d'] rainfall= row['rainfall'] high = row['high'] low = row['low'] rs = iem.query("""SELECT * from summary_%s WHERE station = '%s' and day = '%s'""" % (ts.year, station, date)).dictresult() # Check to see if we should add an entry into the... |
day = '%s'""" % (ts.year, rs[0]['high'], rs[0]['low'], | day = '%s'""" % (ts.year, rs[0]['max_tmpf'], rs[0]['min_tmpf'], | def compare_with_summary(ts, row): station = row['station'] date = row['d'] rainfall= row['rainfall'] high = row['high'] low = row['low'] rs = iem.query("""SELECT * from summary_%s WHERE station = '%s' and day = '%s'""" % (ts.year, station, date)).dictresult() # Check to see if we should add an entry into the... |
shutil.copy(fname, "alerts/%s_%s_%s" \ | shutil.copy("/tmp/"+fname, "alerts/%s_%s_%s" \ | def fireLDM(report, route, id): logger.info("Route! %s" % (route,)) fname = "LOC%sSVRWX.dat" % (route,) fp = open("/tmp/"+fname, 'w') fp.write(report) fp.close() logger.info( report ) try: #if (route != "KELO" and route != "KCCI"): os.system("/home/ldm/bin/pqinsert -p '%s' /tmp/%s" %(fname,fname) ) except: logger.excep... |
sendWindAlert(id, db[id].maxSPED, db[id].maxDrctTxt, myThreshold) | def windGustAlert(): for id in db.keys(): myThreshold = _WIND_THRESHOLD if (id == 84 or id == 40 or id == 9 or id == 78 or id == 49): myThreshold += 7 if (id == 49 or id == 618 or id == 1): myThreshold += 40 # If no obs during this period, no alerts # If no obs during this period, no alerts if (db[id].valid == None): c... | |
os.system("/home/ldm/bin/pqinsert /tmp/wxc_snet8.txt") | os.system("/home/ldm/bin/pqinsert -p wxc_snet8.txt /tmp/wxc_snet8.txt") | def main(): kcci = iemAccessNetwork.iemAccessNetwork("KCCI") kelo = iemAccessNetwork.iemAccessNetwork("KELO") kimt = iemAccessNetwork.iemAccessNetwork("KIMT") kcci.getObs(iemdb) kelo.getObs(iemdb) kimt.getObs(iemdb) kcci.getTrend15(iemdb) kelo.getTrend15(iemdb) kimt.getTrend15(iemdb) kcci.getPrecipTotals(iemdb) kelo.ge... |
bad = numpy.where( bad > 0. and bad < 10000., bad, 0.00024) | bad = numpy.where( bad > 0., bad, 0.00024) bad = numpy.where( bad < 10000., bad, 0.00024) | def merge(ts): """ Process an hour's worth of stage4 data into the hourly RE """ fp = "/mesonet/ARCHIVE/data/%s/stage4/ST4.%s.24h.grib" % ( ts.strftime("%Y/%m/%d"), ts.strftime("%Y%m%d%H") ) grib = Nio.open_file(fp, 'r') # Rough subsample, since the whole enchillata is too much lats = numpy.ravel( grib.variables["g5_... |
tmpfp = iemplot.simple_grid_fill(lons, lats, total / 25.4, cfg) | tmpfp = iemplot.simple_grid_fill(lons, lats, total / 2.54, cfg) | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ sts = ts + mx.DateTime.RelativeDateTime(hour=1, minute=0) ets = ts + mx.DateTime.RelativeDateTime(hour=1, days=1, minute=0) interval = mx.DateTime.RelativeDateTime(hours=1) now = sts total = None lts = None lons = numpy.arange(-110., -8... |
if os.path.isfile(makefp(now)): | if os.path.isfile(make_fp(now)): | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ # First possible file we are interested in.... sts = ts + mx.DateTime.RelativeDateTime(hour=1, minute=0) # Last possible file, base 5 ets = ts - mx.DateTime.RelativeDateTime(minutes= (ts.minute%5)) now = ets total = None lts = None lon... |
nc = netCDF3.Dataset(makefp(now)) | nc = netCDF3.Dataset(make_fp(now)) | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ # First possible file we are interested in.... sts = ts + mx.DateTime.RelativeDateTime(hour=1, minute=0) # Last possible file, base 5 ets = ts - mx.DateTime.RelativeDateTime(minutes= (ts.minute%5)) now = ets total = None lts = None lon... |
def metar_wind(self): """ Return a string for METAR wind information """ if self.sknt is None or self.drct is None: return "" s = "" d5 = self.drct if str(d5)[-1] == "5": d5 -= 5 s += "%03i%02i" % (d5, self.sknt) if self.gust is not None: s += "G%02i" % (self.gust,) s += "KT" return s | def METARtemp(self, inStr): f_temp = float(inStr) i_temp = int( round(f_temp,0) ) f1_temp = int( round(f_temp *10,0) ) if (i_temp < 0): i_temp = 0 - i_temp m_temp = "M"+str( "%02i" % (i_temp) ) else: m_temp = str( "%02i" % (i_temp) ) | |
windTxt = "" if (self.gust != None and self.sknt != None and self.drct != None): drct5 = int(self.drct) if ( int(self.sknt) == 0): drct5 = 0 if (str(self.drct)[-1] == "5"): drct5 = int(self.drct) - 5 elif (int(self.drct) == 0): drct5 = 360 gustTxt = "" if (int(self.gust) > 0): gustTxt = "%s%02i" % ("G", int(self.gust)... | windTxt = self.metar_wind() | def printMETAR(self, out): |
windTxt = "" if (self.gust != None and self.sknt != None and self.drct != None): drct5 = int(self.drct) if ( int(self.sknt) == 0): drct5 = 0 if (str(self.drct)[-1] == "5"): drct5 = int(self.drct) - 5 elif (int(self.drct) == 0): drct5 = 360 gustTxt = "" if (int(self.gust) > 0): gustTxt = "%s%02i" % ("G", int(self.gust)... | windTxt = self.metar_wind() | def printMETAR2(self, out): |
network = sys.argv[1] rs = mesosite.query("SELECT * from stations WHERE network = '%s' ORDER by id DESC" % ( network,)).dictresult() for i in range(len(rs)): sid = rs[i]['id'] | def recover(): """ Account for a stupid processing error I did with not accounting for obs at the end of the month """ network = sys.argv[1] rs = mesosite.query("SELECT * from stations WHERE network = '%s' ORDER by id DESC" % ( network,)).dictresult() for i in range(len(rs)): sid = rs[i]['id'] asos.query("""DELETE fro... | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) try: data = opener.open(url).read() except: print "Fail STID: %s NOW: ... |
WHERE model = %s and runtime = %s and ftime = %s | WHERE model = %s and runtime = %s and ftime = %s and tmp < 999 | def doit(now, model): # Figure out the model runtime we care about mcursor.execute(""" SELECT max(runtime) from alldata where station = 'KDSM' and ftime = %s and model = %s """, (now.strftime("%Y-%m-%d %H:00"), model)) row = mcursor.fetchone() runtime = row[0] if runtime is None: sys.exit() #print "Model Runtime used: ... |
nc = netCDF3.Dataset(fp) | nc = netCDF3.Dataset(makefp(now)) | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ # First possible file we are interested in.... sts = ts + mx.DateTime.RelativeDateTime(hour=1, minute=0) # Last possible file, base 5 ets = ts - mx.DateTime.RelativeDateTime(minutes= (ts.minute%5)) now = ets total = None lts = None lon... |
print now, gts | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) try: data = opener.open(url).read() except: print "Fail STID: %s NOW: ... | |
print sid, now, obs | def recover(): """ Account for a stupid processing error I did with not accounting for obs at the end of the month """ network = sys.argv[1] rs = mesosite.query("SELECT * from stations WHERE network = '%s' ORDER by id DESC" % ( network,)).dictresult() for i in range(len(rs)): sid = rs[i]['id'] # Delete all obs from the... | |
print sid, ts, obs | def recover(): """ Account for a stupid processing error I did with not accounting for obs at the end of the month """ network = sys.argv[1] rs = mesosite.query("SELECT * from stations WHERE network = '%s' ORDER by id DESC" % ( network,)).dictresult() for i in range(len(rs)): sid = rs[i]['id'] # Delete all obs from the... | |
print 'HTTP ERROR' | print 'HTTP ERROR Station: %s Model: %s' % (station, model) | def run(model, station, lon, lat, ts): """ Ingest the model data for a given Model, stationid and timestamp """ vstring = "" for v in VLOOKUP: if VLOOKUP[v][model] is not None: vstring += "var=%s&" % (VLOOKUP[v][model],) url = "%s%s?%slatitude=%s&longitude=%s&temporal=all&vertCoord=&accept=csv&point=true" % (BASE_URL... |
if mtr is not None: | if mtr is not None and mtr.time is not None: | def doit(stid, now): metarPass = 0 metarFail = 0 processed = 0 sqlFail = 0 url = "http://www.wunderground.com/history/airport/K%s/%s/%-i/%-i/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1" % (stid, now.year, now.month, now.day) try: data = opener.open(url).read() except: print "Fail STID: %s NOW: ... |
offset = int((ts - (ts + mx.DateTime.RelativeDateTime(month=1,day=1,hour=1))).days) | offset = int((ts - (ts + mx.DateTime.RelativeDateTime(month=1,day=1,hour=0))).days) | def grid_day(nc, ts): """ I proctor the gridding of data on an hourly basis @param ts Timestamp of the analysis, we'll consider a 20 minute window """ offset = int((ts - (ts + mx.DateTime.RelativeDateTime(month=1,day=1,hour=1))).days) sql = """SELECT * from alldata WHERE day = '%s' and stationid != 'ia0000' """ % ( t... |
ts = mx.DateTime.now() - mx.DateTime.RelativeDateTime(days=1) | ts = mx.DateTime.now() - mx.DateTime.RelativeDateTime(days=1,hour=0,minute=0, second=0) | def main(ts): # Load up a station table we are interested in load_stationtable() # Load up our netcdf file! nc = netCDF3.Dataset("/mnt/mesonet/data/iemre/%s_daily.nc" % (ts.year,), 'a') grid_day(nc , ts) nc.close() |
print "USING %s NCVAR %s DIVISOR %s" % (fp, ncvar, divisor) | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ sts = ts + mx.DateTime.RelativeDateTime(hour=1, minute=0) ets = ts + mx.DateTime.RelativeDateTime(hour=1, days=1, minute=0) interval = mx.DateTime.RelativeDateTime(hours=1) now = sts total = None lts = None lons = numpy.arange(-110., -8... | |
ts = mx.DateTime.strptime(data['date_time'], '%Y-%m-%d %H:%M:%S') | ts = mx.DateTime.strptime(data['date_time'][:16], '%Y-%m-%d %H:%M') | def processfile( fp ): o = open("/mesonet/data/incoming/rwis/%s" % (fp,), 'r').readlines() if len(o) < 2: return heading = o[0].split(",") cols = o[1].split(",") data = {} for i in range(len(heading)): if cols[i].strip() != "/": data[ heading[i].strip() ] = cols[i].strip() #print data nwsli = lkp[ fp ] iem = iemAccess... |
sts = ts + mx.DateTime.RelativeDateTime(hour=1) ets = ts + mx.DateTime.RelativeDateTime(hour=1, days=1) | sts = ts + mx.DateTime.RelativeDateTime(hour=1, minute=0) ets = ts + mx.DateTime.RelativeDateTime(hour=1, days=1, minute=0) | def doday(ts): """ Create a plot of precipitation stage4 estimates for some day """ sts = ts + mx.DateTime.RelativeDateTime(hour=1) ets = ts + mx.DateTime.RelativeDateTime(hour=1, days=1) interval = mx.DateTime.RelativeDateTime(hours=1) now = sts total = None lts = None while now < ets: fp = "/mesonet/ARCHIVE/data/%s/s... |
elif rs[i][ data1 ] is None or rs[i][ data1 ] <= -99.0: | elif rs[i][ data1 ] is None or rs[i][ data1 ] <= -99.0 or rs[i][ data1 ] == "M": | def Main(): print "Content-type: text/plain \n\n", form = cgi.FormContent() if (not form.has_key("station")): print "Station Not defined. Error" sys.exit(0) station = (string.strip( form["station"][0] )).upper() gisextra = [] if form.has_key("latlon") and form["latlon"][0] == "yes": rs = mesositedb.query("SELECT x(geo... |
nc = netCDF3.Dataset(make_fp(lts)) | fp = make_fp(lts) if not os.path.isfile(fp): continue nc = netCDF3.Dataset( fp ) | def doit(ts, hours): """ Create a plot of precipitation stage4 estimates for some day """ # Mod the minute down remain = ts.minute % 5 ts -= mx.DateTime.RelativeDateTime(minutes=(ts.minute%5)) lons = numpy.arange(-110., -89.99, 0.01) lats = numpy.arange(55.0, 39.99, -0.01) limit = 20 while not os.path.isfile(make_fp(... |
sys.stdout.write( rD.join( gisextra ) ) | sys.stdout.write( gtxt ) | def Main(): print "Content-type: text/plain \n\n", form = cgi.FormContent() if (not form.has_key("station")): print "Station Not defined. Error" sys.exit(0) station = (string.strip( form["station"][0] )).upper() gisextra = [] if form.has_key("latlon") and form["latlon"][0] == "yes": rs = mesositedb.query("SELECT x(geo... |
if self.obs[sid].gmt_ts > self.thres: | if self.obs[sid].gmt_ts > thres: | def iemtracker(self): """ Check the observations against IEM Tracker to see if we need to squawk """ try: import tracker except: print "Could not connect to Portfolio Database, continuing" return dontmail = self.checkOffline('IA_RWIS', 300) thres = mx.DateTime.gmt() - mx.DateTime.RelativeDateTime(hours=3) track = track... |
Used in boolean context, fails if non-true. These all fail: | Used in boolean context, fails if non-true. These all fail:: | def run(self, formatter=FancyFormatter): """Run all tests in this collection. |
for index, line in enumerate(lines): if __file__[0:-1] in line: del lines[index] del lines[index] formatter.failure(test, e, '\n'.join(lines)) | clean = lines[0:1] stack = iter(lines[1:-1]) for first, second in zip(stack, stack): if __file__[0:-1] not in first: clean.extend((first, second)) clean.append(lines[-1]) formatter.failure(test, e, '\n'.join(clean)) | def run(self, formatter=FancyFormatter): """Run all tests in this collection. |
if dist.parsed_version[:level] > parsed_version[:level]: | trunked_current = list(parsed_version[:level]) trunked_candidate = list(dist.parsed_version[:level]) if '*final' in trunked_candidate: trunked_candidate.remove('*final') while len(trunked_candidate) < level: trunked_candidate.append('00000000') if '*final' in trunked_current: trunked_current.remove('*final') while len... | def check(self, level=0): """Search new versions in a version list versions must be a dict {'name': 'version'} |
trunked_current = list(parsed_version[:level]) trunked_candidate = list(dist.parsed_version[:level]) if '*final' in trunked_candidate: trunked_candidate.remove('*final') | trunked_current = [x for x in parsed_version[:level] if not x.startswith('*')] trunked_candidate = [x for x in dist.parsed_version[:level] if not x.startswith('*')] | def check(self, level=0): """Search new versions in a version list versions must be a dict {'name': 'version'} |
if '*final' in trunked_current: trunked_current.remove('*final') | def check(self, level=0): """Search new versions in a version list versions must be a dict {'name': 'version'} | |
body = '301 Moved Permanently' status = '301 %s' % body | body = 'See Other' status = '303 %s' % body | def POST(self, name): document_uri = join(DB_URI, '%s.md' % name) length = int(self.environ['CONTENT_LENGTH']) input_data = self.environ['wsgi.input'].read(length) input_data = parse_qs(input_data) |
mks.extend(mk_persons) | mks.extend([person.mk for person in mk_persons]) | def get_protocols(self, max_page=10): SEARCH_URL = "http://www.knesset.gov.il/protocols/heb/protocol_search.aspx" cj = cookielib.LWPCookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) |
complete_apps = ['mks'] | complete_apps = ['committees', 'mks'] | def backwards(self, orm): "Write your backwards methods here." |
r = re.search("""<td class="LawText1">(.*)</td>""",line) | r = re.search("""<td class="LawText1">(.*)""",line) | def parse_laws_page(self,page): names = [] exps = [] links = [] count = -1 lines = page.split('\n') for line in lines: #print line r = re.search("""Href=\"(.*?)\">""",line) if r != None: link = 'http://www.knesset.gov.il/privatelaw/' + r.group(1) r = re.search("""<td class="LawText1">(.*)</td>""",line) if r != None: na... |
name = r.group(1) if len(name)>0: | name = r.group(1).replace("</td>","").strip() if len(name)>1 and name.find('span')<0: | def parse_laws_page(self,page): names = [] exps = [] links = [] count = -1 lines = page.split('\n') for line in lines: #print line r = re.search("""Href=\"(.*?)\">""",line) if r != None: link = 'http://www.knesset.gov.il/privatelaw/' + r.group(1) r = re.search("""<td class="LawText1">(.*)</td>""",line) if r != None: na... |
parties = dict() | def update_db_from_files(self): print "Update DB From Files" | |
v = votes[vote_id] | try: v = votes[vote_id] except KeyError: continue | def update_db_from_files(self): print "Update DB From Files" |
return (for_score - against_score) / max_score * 100 | if max_score > 0: return (for_score - against_score) / max_score * 100 else: return 0.0 | def member_score(self, member): # Find all votes that # 1) This agenda is ascribed to # 2) the member participated in and either voted for or against for_score = AgendaVote.objects.filter(agenda=self,vote__voteaction__member=member,vote__voteaction__type="for").distinct().aggregate(Sum('score'))['score__sum']... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.