Create clean filenames with center date for velocity maps generated from WV DEMs """ #Rename all #mkdir vm #for i in */2*vm.tif; do ln -s ../$i vm/$(~/src/vmap/vmap/wv_cdate.py $i)_vm.tif; done #parallel "fn=$(~/src/vmap/vmap/wv_cdate.py {}); ln -s ../{} vm/${fn}_vm.tif" ::: */2*vm.tif import os fn = sys.argv[1] dt_list = timelib.fn_getdatetime_list(fn) dt_list = np.sort(dt_list) dtmin = dt_list.min() dtmax = dt_list.max() c_date = timelib.mean_date(dt_list) ndays = timelib.dt_ptp(dt_list) ndays = timelib.dt_ptp((dtmin, dtmax)) nyears = ndays/365.25 #s = '%s_%04idays_%s-%s' % (c_date.strftime('%Y%m%d'), ndays, dtmin.strftime('%Y%m%d'), dtmax.strftime('%Y%m%d')) #s = '%s_%s-%s_%0.2fyr' % (c_date.strftime('%Y%m%d'), dtmin.strftime('%Y%m%d'), dtmax.strftime('%Y%m%d'), nyears) #s = '%s_%s-%s_%04iday' % (c_date.strftime('%Y%m%d'), dtmin.strftime('%Y%m%d'), dtmax.strftime('%Y%m%d'), ndays) #Added %H%M here, as there were some inputs acquired on same days s = '%s__%s-%s__%04iday' % (c_date.strftime('%Y%m%d_%H%M'), dtmin.strftime('%Y%m%d_%H%M'), dtmax.strftime('%Y%m%d_%H%M'), ndays) print(s) #outdir="vm" #if not os.path.exists(outdir): # os.makedirs(outdir) #os.symlink(os.path.join("..", fn), os.path.join(outdir, s+'_vm.tif'))
#z2_fn = '/nobackup/deshean/hma/hma1_2016dec22/hma_8m_tile/hma_8m.vrt' #z2_fn = os.path.join(topdir,'hma/hma1_2016dec22/hma_8m_tile/hma_8m.vrt') #z2_fn = os.path.join(topdir,'hma/hma1_2016dec22/hma_8m_tile_round2_20170220/hma_8m_round2.vrt') #z2_fn = os.path.join(topdir,'hma/hma_8m_mos_20170410/hma_8m.vrt') z2_fn = os.path.join(topdir, 'hma/mos/%s/mos_8m/%s_8m.vrt' % (mosdir, mosdir)) #z2_date = 2015.0 z2_date = datetime(2015, 1, 1) elif site == 'other': outdir = os.path.join(topdir, 'mb') aea_srs = geolib.conus_aea_srs #glac_shp_fn = '/Users/dshean/data/conus_glacierpoly_24k/rainier_24k_1970-2015_mb_aea.shp' #glac_shp_fn = '/Users/dshean/data/conus_glacierpoly_24k/conus_glacierpoly_24k_aea.shp' glac_shp_fn = '/Users/dshean/data/conus_glacierpoly_24k/conus_glacierpoly_24k_32610_scg_2008_aea.shp' z1_fn = sys.argv[1] z1_date = timelib.mean_date(timelib.fn_getdatetime_list(z1_fn)) z2_fn = sys.argv[2] z2_date = timelib.mean_date(timelib.fn_getdatetime_list(z2_fn)) else: sys.exit() ts = datetime.now().strftime('%Y%m%d_%H%M') out_fn = '%s_mb_%s.csv' % (site, ts) out_fn = os.path.join(outdir, out_fn) #Write out temporary file line by line, incase processes interrupted import csv f = open(os.path.splitext(out_fn)[0] + '_temp.csv', 'wb') writer = csv.writer(f) #List to hold output