xdenisx

rep_central

Apr 10th, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import inspect
  4. import os
  5. import sys
  6. import glob
  7.  
  8. from nansat import Nansat, Domain
  9.  
  10. def process(ffile):
  11.     print ffile.split('/')[-1]
  12.     n = Nansat(ffile)
  13.     #print n
  14.     #repojection
  15.     srsString = "+proj=stere +lon_0=0 +lat_0=90 +k=1 +ellps=WGS84 +datum=WGS84 +no_defs"
  16.     extentString = "-lle 95.0 65.0 110.0 90.0 -tr 100 100"
  17.     n.reproject_GCPs(srsString)
  18.     dStereo = Domain(srsString, extentString)
  19.     n.reproject(dStereo, 2)
  20.     # land mask
  21.     wm = n.watermask()
  22.     wmArray = wm[1]
  23.     out_f = 'reprojected/ps_' + ffile.split('/')[-1] + '.tif'
  24.     # save a figure
  25.     # n.write_figure(out_f, transparentMask=True, mask_array=wmArray, mask_lut={0: [0,0,0]}, bands=[3], cmapName='gray', transparency=[0,0,0])
  26.     n.write_figure(out_f, bands=3, mask_array=wmArray, mask_lut={0: [0,0,0]}, clim=[0,0.7], logarithm=True, gamma=2, cmapName='gray')
  27.  
  28.  
  29. files_path = sys.argv[1]
  30. ffiles = glob.glob(files_path)
  31.  
  32. for ffile in ffiles:
  33.     #print "\nStart processing %s ..." % ffile
  34.     try:
  35.         process(ffile)
  36.     except:
  37.         print "Error!"
Advertisement
Add Comment
Please, Sign In to add comment