Created
August 6, 2012 17:23
-
-
Save smacfarlane/3276909 to your computer and use it in GitHub Desktop.
Quick load of modis data using pytroll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
#First, lets load up the scene into pytroll | |
import os | |
import fnmatch | |
import datetime | |
import glob | |
from mpop.scene import assemble_segments | |
from mpop.satellites import PolarFactory | |
from mpop.satin import hdfeos_l1b | |
name = "t1.12192.2208" | |
t = datetime.datetime(2012,7,10,22,8) | |
unprojected_data = PolarFactory.create_scene("terra","","modis", t, "") | |
bands = set(['36']) | |
resolutions = set(['1000']) | |
unprojected_data.load(bands) | |
#Then we want to try saving it out as a "Flat Binary File" | |
for band in bands: | |
outfile = file("{name}.{band}.fbf".format(name=name,band=band), 'wb') | |
unprojected_data[band].get_data().data.tofile(outfile) | |
outfile.close() | |
for resolution in resolutions: | |
lats = file("{name}.{res}.lat.fbf".format(name=name,res=resolution), 'wb') | |
lons = file("{name}.{res}.lon.fbf".format(name=name,res=resolution), 'wb') | |
lat, lon = hdfeos_l1b.get_lat_lon(unprojected_data, resolution, "{name}.geo.hdf".format(name=name)) | |
lat.data.tofile(lats) | |
lon.data.tofile(lons) | |
lats.close() | |
lons.close() | |
rows,cols = unprojected_data.area.shape | |
print "Rows: {rows}, Cols: {cols}".format(rows=rows,cols=cols) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment