Skip to content

Commit

Permalink
Updated directory location
Browse files Browse the repository at this point in the history
  • Loading branch information
sambowers committed Feb 9, 2018
1 parent 833267f commit 7592015
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions biota/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,18 @@ def __getSatellite(self):

def __getDirectory(self):
"""
Return the directory containing ALOS data for a given lat/lon.
Return the directory containing ALOS data for a given lat/lon. Assumes its distributed as a 5x5 tile at present.
"""

# Calculate the hemisphere and lat/lon of the 5x5 tile
lat_dir = self.lat + (5 - self.lat) % 5
lon_dir = self.lon - (self.lon % 5)
hem_NS_dir = 'S' if lat_dir < 0 else 'N'
hem_EW_dir = 'W' if lon_dir < 0 else 'E'

# Get lat/lon for directory (lat/lon of upper-left hand corner of 5x5 tiles)
lat_dir = self.hem_NS + str(abs(self.lat + (5 - self.lat) % 5)).zfill(2)
lon_dir = self.hem_EW + str(abs(self.lon - (self.lon % 5))).zfill(3)
lat_dir = hem_NS_dir + str(abs(lat_dir)).zfill(2)
lon_dir = hem_EW_dir + str(abs(lon_dir)).zfill(3)

# Directories and files have standardised pattern
name_pattern = '%s%s_%s_%s'
Expand Down Expand Up @@ -538,7 +544,7 @@ def getAGB(self, lee_filter = True, output = False):
AGB = 715.667 * self.getGamma0(units = 'natural', polarisation = 'HV', lee_filter = lee_filter) - 5.967

else:
raise ValueError("Unknown satellite named ''. self.satellite must be 'ALOS-1' or 'ALOS-2'."%self.satellite)
raise ValueError("Unknown satellite named '%s'. self.satellite must be 'ALOS-1' or 'ALOS-2'."%self.satellite)

# Keep masked values tidy
AGB.data[self.mask] = 0.
Expand Down

0 comments on commit 7592015

Please sign in to comment.