def main ( tile, start_date, end_date ): """ Main function """ from modisficator import get_modis_data import pylab import datetime if not os.path.exists(os.path.expanduser("~/Data/AF_inversions")): # Directory doesn't exist. Create it. os.mkdir ( os.path.expanduser("~/Data/AF_inversions") ) print "Making dir %s" % os.path.expanduser("~/Data/AF_inversions") print "Stuff will be saved there" fname = os.path.expanduser("~/Data/AF_inversions") + \ "/%s_%s_%s.dat" % ( tile, start_date, end_date) f = open( fname, 'w') MAX_NUM_FIRES_TILE = 100 global TILE global FECHA TILE = tile for retval in get_modis_data( tile, "MOD14A1", \ start_date, end_date=end_date): # Apparently, GDAL doesn't do unicode hdf_file = (retval[1]).encode( 'ascii' ) print "Doing file", hdf_file sys.stdout.flush() afires = get_active_fires ( hdf_file ) for dates in afires.iterkeys(): print "Doing date", dates sys.stdout.flush() num_fires = 0 for detection in afires[dates]: D = get_nbar_rho ( detection[0], \ detection[1], dates ) #pdb.set_trace() FECHA = dates retonno = do_tseries_plots ( D, dates) if retonno != None: # An "optical fire" was detected ( fcc, a0, a1, a2, store_file ) = retonno f.write ( "%s ; %f ; %f ; %f ; %f ; %f ; %f ; %s\n" % ( \ dates, detection[0], detection[1], fcc, a0, a1, a2, \ store_file ) ) num_fires += 1 f.flush() if num_fires > MAX_NUM_FIRES_TILE: break f.close()
def main(tile, start_date, end_date): """ Main function """ from modisficator import get_modis_data import pylab import datetime if not os.path.exists(os.path.expanduser("~/Data/AF_inversions")): # Directory doesn't exist. Create it. os.mkdir(os.path.expanduser("~/Data/AF_inversions")) print "Making dir %s" % os.path.expanduser("~/Data/AF_inversions") print "Stuff will be saved there" fname = os.path.expanduser("~/Data/AF_inversions") + \ "/%s_%s_%s.dat" % ( tile, start_date, end_date) f = open(fname, 'w') MAX_NUM_FIRES_TILE = 100 global TILE global FECHA TILE = tile for retval in get_modis_data( tile, "MOD14A1", \ start_date, end_date=end_date): # Apparently, GDAL doesn't do unicode hdf_file = (retval[1]).encode('ascii') print "Doing file", hdf_file sys.stdout.flush() afires = get_active_fires(hdf_file) for dates in afires.iterkeys(): print "Doing date", dates sys.stdout.flush() num_fires = 0 for detection in afires[dates]: D = get_nbar_rho ( detection[0], \ detection[1], dates ) #pdb.set_trace() FECHA = dates retonno = do_tseries_plots(D, dates) if retonno != None: # An "optical fire" was detected (fcc, a0, a1, a2, store_file) = retonno f.write ( "%s ; %f ; %f ; %f ; %f ; %f ; %f ; %s\n" % ( \ dates, detection[0], detection[1], fcc, a0, a1, a2, \ store_file ) ) num_fires += 1 f.flush() if num_fires > MAX_NUM_FIRES_TILE: break f.close()
def main(tile, start_date, end_date): from modisficator import get_modis_data import pylab import datetime import cPickle f = open("test/sample.pkl", 'w') for retval in get_modis_data( tile, "MOD14A1", \ start_date, end_date=end_date): # Apparently, GDAL doesn't do unicode hdf_file = (retval[1]).encode('ascii') afires = get_active_fires(hdf_file) for dates in afires.iterkeys(): for detection in afires[dates]: D = get_nbar_rho ( detection[0], \ detection[1], dates ) #pdb.set_trace() do_tseries_plots(D, dates) cPickle.dump((D, dates), f) break break break f.close()
def main ( tile, start_date, end_date ): from modisficator import get_modis_data import pylab import datetime import cPickle f = open("test/sample.pkl", 'w') for retval in get_modis_data( tile, "MOD14A1", \ start_date, end_date=end_date): # Apparently, GDAL doesn't do unicode hdf_file = (retval[1]).encode( 'ascii' ) afires = get_active_fires ( hdf_file ) for dates in afires.iterkeys(): for detection in afires[dates]: D = get_nbar_rho ( detection[0], \ detection[1], dates ) #pdb.set_trace() do_tseries_plots ( D, dates) cPickle.dump ( (D, dates), f ) break break break f.close()