def test_bin(pid): #client = Client() client = Filesystem(['../exampleData']) catch = False dir = os.path.join('stitch', ifcb.lid(pid)) try: os.mkdir(dir) except: pass unstitched = client.resolve(pid) stitched = StitchedBin(unstitched) print stitched pairs = list(find_pairs(unstitched)) for target, ignore in pairs: t = stitched.target(target) print 'Got %s' % t basename = ifcb.lid(t.pid) t.image().save(os.path.join(dir, basename + '.png'), 'png') t.mask().save(os.path.join(dir, basename + '_mask.png'), 'png') t.stitch_raw().save(os.path.join(dir, basename + '_raw.png'), 'png')
def test_bin(pid): #client = Client() client = Filesystem(['../exampleData']) catch = False dir = os.path.join('stitch',ifcb.lid(pid)) try: os.mkdir(dir) except: pass unstitched = client.resolve(pid) stitched = StitchedBin(unstitched) print stitched pairs = list(find_pairs(unstitched)) for target,ignore in pairs: t = stitched.target(target) print 'Got %s' % t basename = ifcb.lid(t.pid) t.image().save(os.path.join(dir,basename+'.png'),'png') t.mask().save(os.path.join(dir,basename+'_mask.png'),'png') t.stitch_raw().save(os.path.join(dir,basename+'_raw.png'),'png')
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)
if re.match(r'^\d{4}-\d{2}-\d{2}$',dates): # is it an unadorned yyyy-mm-dd? date = time.strptime(dates+'UTC','%Y-%m-%d%Z') # assume midnight UTC elif re.match(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$',dates): # ISO 8601 in YYYY-mm-ddTHH:MM:SSZ? date = time.strptime(re.sub('Z$','UTC',dates),'%Y-%m-%dT%H:%M:%S%Z') # parse dayss = cgi.FieldStorage().getvalue('day',None) if dayss is not None: if re.match(r'^\d{4}-\d{2}-\d{2}$',dayss): # is it an unadorned yyyy-mm-dd? date = time.strptime(dayss+'UTC','%Y-%m-%d%Z') # assume midnight UTC elif re.match(r'^\d{4}-\d{3}$',dayss): # is it a julian day (yyyy-jjj)? date = time.strptime(dayss+'UTC','%Y-%j%Z') fs = Filesystem(FS_ROOTS) if dayss is not None: bin_ids = list(day_bins(date)) else: bin_ids = list(latest_bins(size,date)) bins = [fs.resolve(pid) for pid in bin_ids] mime = dict(atom='application/atom+xml', json='application/json', html='text/html', rss='application/rss+xml')[format] headers = ['Content-type: %s' % mime, 'Cache-control: max-age=60', ''] for h in headers: print h link = '.'.join([FEED,format]) if format == 'atom': bins2atom(bins,link) elif format == 'json': bins2json_feed(bins) elif format == 'rss': bins2rss(bins,link) elif format == 'html': bins2html_feed(bins)
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)