def test4(): bin = J.bin(ifcb.pid('IFCB5_2011_056_024112')) bin2html(bin) bin2json(bin) print '' bin2xml(bin) bin2adc(bin) bin2hdr(bin)
def latest_bins(n=25,date=None): if date is None: date = time.gmtime() dt = utcdatetime(date) c = psql.connect(PSQL_CONNECT) db = c.cursor() db.execute("select lid,sample_time from bins where sample_time <= %s order by sample_time desc limit %s",(dt,n)) # dangling comma is necessary for row in db.fetchall(): yield ifcb.pid(row[0])
def __init__(self, path): self.dir = os.path.dirname(os.path.abspath(path)) file = os.path.basename(path) (self.id, ext) = os.path.splitext(file) # the timestamp is the approximate time the syringe was sampled and flow began self.pid = ifcb.pid(self.id) self.oid = parse_id(self.id) self.time_string = self.oid.datetime self.instrument = self.oid.instrument_number self.time_format = self.oid.datetime_format
def day_bins(date=None): if date is None: date = time.gmtime() dt = utcdatetime(date) c = psql.connect(PSQL_CONNECT) db = c.cursor() db.execute("set session time zone 'UTC'") db.execute("select lid,sample_time from bins where date_part('year',sample_time) = %s and date_part('month',sample_time) = %s and date_part('day',sample_time) = %s order by sample_time desc",(dt.year,dt.month,dt.day)) for row in db.fetchall(): yield ifcb.pid(row[0])
def test5(): target = J.target(ifcb.pid('IFCB5_2011_056_024112_000001')) target2xml(target) target2html(target) target2rdf(target)
def __repr__(self): return ifcb.pid(self.lid)
def as_pid(self): return ifcb.pid(self.lid)
def pid(self): if no_day_dirs(): return self.dir return ifcb.pid(os.path.basename(self.dir))
from config import FS_ROOTS from ifcb.io.path import Filesystem import mosaic import sys import ifcb if __name__=='__main__': if len(sys.argv) < 2: print >> sys.stderr, 'usage: %s [pid] [outputfile]' % sys.argv[0] else: fs = Filesystem(FS_ROOTS) b = fs.resolve(ifcb.pid(sys.argv[1])) outfile = None if len(sys.argv) > 2: outfile = sys.argv[2] print >> sys.stderr, 'Generating mosaic for %s' % str(b) mosaic.save_mosaic(b,outfile)
def __target(self, pid): oid = parse_id(pid) bin = self.bin(ifcb.pid(oid.bin_lid)) return bin.target(int(oid.target)) # bin.target is 0-based
from config import FS_ROOTS from ifcb.io.path import Filesystem import mosaic import sys import ifcb if __name__ == '__main__': if len(sys.argv) < 2: print >> sys.stderr, 'usage: %s [pid] [outputfile]' % sys.argv[0] else: fs = Filesystem(FS_ROOTS) b = fs.resolve(ifcb.pid(sys.argv[1])) outfile = None if len(sys.argv) > 2: outfile = sys.argv[2] print >> sys.stderr, 'Generating mosaic for %s' % str(b) mosaic.save_mosaic(b, outfile)