Skip to content

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshempelmann committed Jan 7, 2019
1 parent 7d6f82d commit 0844b51
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 38 deletions.
5 changes: 3 additions & 2 deletions eggshell/eo/gdal_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def GetOutputDriversFor(filename):
ext = GetExtension(filename)
for i in range(gdal.GetDriverCount()):
drv = gdal.GetDriver(i)
if (drv.GetMetadataItem(gdal.DCAP_CREATE) is not None
or drv.GetMetadataItem(gdal.DCAP_CREATECOPY) is not None) and drv.GetMetadataItem(gdal.DCAP_RASTER) is not None:
if (drv.GetMetadataItem(gdal.DCAP_CREATE) is not None or
drv.GetMetadataItem(gdal.DCAP_CREATECOPY) is not None) and
drv.GetMetadataItem(gdal.DCAP_RASTER) is not None:
if len(ext) > 0 and DoesDriverHandleExtension(drv, ext):
drv_list.append(drv.ShortName)
else:
Expand Down
11 changes: 6 additions & 5 deletions eggshell/nc/nc_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def write_fileinfo(resource, filepath=False):
for f in resource:
fp.write('%s \n' % realpath(f))
LOGGER.info('resources filenames written to textfile')
except:
LOGGER.exception('failed to write file names to file')
except Exception as ex:
LOGGER.exception('failed to write file names to file {}'.format(ex))

return text_src

Expand Down Expand Up @@ -282,10 +282,10 @@ def write_fileinfo(resource, filepath=False):
# "assets.analytic_b11:download",
# "assets.analytic_b12:download"
# ],
#


# def fetch_eodata(item_type, asset, token, bbox, period=[dt.today()-timedelta(days=30), dt.today()], cloud_cover=0.5, cache=True):
# def fetch_eodata(item_type, asset, token, bbox, period=[dt.today()-timedelta
# (days=30), dt.today()], cloud_cover=0.5, cache=True):
# """
# search for given EO data product provided by planet.
# The search and appropriate download is limited by bbox and search period
Expand Down Expand Up @@ -409,7 +409,8 @@ def write_fileinfo(resource, filepath=False):
# else:
# id0_url = 'https://api.planet.com/data/v1/item-types/{}/items/{}/assets'.format(item_type, id0)
#
# # Returns JSON metadata for assets in this ID. Learn more: planet.com/docs/reference/data-api/items-assets/#asset
# # Returns JSON metadata for assets in this ID. Learn more:
# planet.com/docs/reference/data-api/items-assets/#asset
# result = requests.get(id0_url, auth=HTTPBasicAuth(PLANET_API_KEY, ''))
# # List of asset types available for this particular satellite image
# keys = result.json().keys()
Expand Down
7 changes: 4 additions & 3 deletions eggshell/nc/nc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# from eggshell.nc.ocg_utils import get_variable
import logging
import os
from os import path, rename
import requests

LOGGER = logging.getLogger("PYWPS")
Expand Down Expand Up @@ -670,8 +671,8 @@ def get_values(resource, variable=None):
# ds.close()
#
# return lats, lons
#
#


def drs_filename(resource, skip_timestamp=False, skip_format=False,
variable=None, rename_file=False, add_file_path=False):
"""
Expand All @@ -690,7 +691,7 @@ def drs_filename(resource, skip_timestamp=False, skip_format=False,
:param rename_file: rename the file. (default: False)
:returns str: DRS filename
"""
from os import path, rename


try:
ds = Dataset(resource)
Expand Down
57 changes: 29 additions & 28 deletions eggshell/nc/ocg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,33 @@

# This should replace calc_grouping, as it provides direct access to keys and makes inspection easier.
temp_groups = {'AMJJAS': [[4, 5, 6, 7, 8, 9], 'unique'],
'Apr': [[4], 'unique'],
'Aug': [[8], 'unique'],
'DJF': [[12, 1, 2], 'unique'],
'Dec': [[12], 'unique'],
'Feb': [[2], 'unique'],
'JJA': [[6, 7, 8], 'unique'],
'Jan': [[1], 'unique'],
'Jul': [[7], 'unique'],
'Jun': [[6], 'unique'],
'MAM': [[3, 4, 5], 'unique'],
'Mar': [[3], 'unique'],
'May': [[5], 'unique'],
'Nov': [[11], 'unique'],
'ONDJFM': [[10, 11, 12, 1, 2, 3], 'unique'],
'Oct': [[10], 'unique'],
'SON': [[9, 10, 11], 'unique'],
'Sep': [[9], 'unique'],
'day': ['year', 'month', 'day'],
'mon': ['year', 'month'],
'sem': [[12, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], 'unique'],
'yr': ['year']}

'Apr': [[4], 'unique'],
'Aug': [[8], 'unique'],
'DJF': [[12, 1, 2], 'unique'],
'Dec': [[12], 'unique'],
'Feb': [[2], 'unique'],
'JJA': [[6, 7, 8], 'unique'],
'Jan': [[1], 'unique'],
'Jul': [[7], 'unique'],
'Jun': [[6], 'unique'],
'MAM': [[3, 4, 5], 'unique'],
'Mar': [[3], 'unique'],
'May': [[5], 'unique'],
'Nov': [[11], 'unique'],
'ONDJFM': [[10, 11, 12, 1, 2, 3], 'unique'],
'Oct': [[10], 'unique'],
'SON': [[9, 10, 11], 'unique'],
'Sep': [[9], 'unique'],
'day': ['year', 'month', 'day'],
'mon': ['year', 'month'],
'sem': [[12, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], 'unique'],
'yr': ['year']}
# # TODO: include regridding with ocgis

def call(resource=[], variable=None, dimension_map=None, agg_selection=True, calc=None,
calc_grouping=None, conform_units_to=None, crs=None, memory_limit=None, prefix=None,

def call(resource=[], variable=None, dimension_map=None, agg_selection=True,
calc=None, calc_grouping=None, conform_units_to=None, crs=None,
memory_limit=None, prefix=None,
regrid_destination=None, regrid_options='bil', level_range=None, # cdover='python',
geom=None, output_format_options=None, search_radius_mult=2.,
select_nearest=False, select_ugid=None, spatial_wrapping=None,
Expand Down Expand Up @@ -103,8 +104,8 @@ def call(resource=[], variable=None, dimension_map=None, agg_selection=True, cal
# dt.combine(time_range[1], dt_time(12,0))]
LOGGER.debug('time_range changed to type= %s , %s ' % (type(time_range[0]), type(time_range[1])))
LOGGER.debug('time_range changed to= %s , %s ' % (time_range[0], time_range[1]))
except:
LOGGER.exception('failed to convert data to datetime')
except Exception as ex:
LOGGER.exception('failed to convert data to datetime {}'.format(ex))

if spatial_wrapping == 'wrap':
spatial_reorder = True
Expand Down Expand Up @@ -166,7 +167,7 @@ def call(resource=[], variable=None, dimension_map=None, agg_selection=True, cal
LOGGER.exception('failed to setup OcgOperations: {}'.format(ex))
return None

#TODO include comaprison dataload to available memory
# TODO include comaprison dataload to available memory

dataload = 1
available_memory = 2
Expand Down Expand Up @@ -326,7 +327,7 @@ def call(resource=[], variable=None, dimension_map=None, agg_selection=True, cal
# lat, lon = unrotate_pole(output)
# except:
# LOGGER.exception('failed to unrotate pole')
# output
# output


def calc_grouping(grouping):
Expand Down

0 comments on commit 0844b51

Please sign in to comment.