From 5ec72a88bb4df13c83024da40ffd34e18d785480 Mon Sep 17 00:00:00 2001 From: chenghuzi Date: Thu, 19 Mar 2020 01:22:21 -0400 Subject: [PATCH 1/3] add gitignore --- .gitignore | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd78eef --- /dev/null +++ b/.gitignore @@ -0,0 +1,143 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# static files generated from Django application using `collectstatic` +media +static \ No newline at end of file From ca4702f13b37502d01bedc24831399da7c471c37 Mon Sep 17 00:00:00 2001 From: chenghuzi Date: Thu, 19 Mar 2020 01:23:53 -0400 Subject: [PATCH 2/3] fix params error --- ridge_map/ridge_map.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ridge_map/ridge_map.py b/ridge_map/ridge_map.py index 4fcfcb5..eb0559e 100644 --- a/ridge_map/ridge_map.py +++ b/ridge_map/ridge_map.py @@ -80,12 +80,12 @@ def __init__(self, bbox=(-71.928864, 43.758201, -70.957947, 44.465151), font=Non @property def lats(self): """Left and right latitude of bounding box.""" - return (self.bbox[1], self.bbox[3]) + return (self.bbox[0], self.bbox[2]) @property def longs(self): """Bottom and top longitude of bounding box.""" - return (self.bbox[0], self.bbox[2]) + return (self.bbox[1], self.bbox[3]) def get_elevation_data(self, num_lines=80, elevation_pts=300, viewpoint="south"): """Fetch elevation data and return a numpy array. @@ -153,7 +153,8 @@ def preprocess( values = (values - np.min(values)) / (np.max(values) - np.min(values)) is_water = values < np.percentile(values, water_ntile) - is_lake = rank.gradient(img_as_ubyte(values), square(3)) < lake_flatness + is_lake = rank.gradient(img_as_ubyte( + values), square(3)) < lake_flatness values[nan_vals] = np.nan values[np.logical_or(is_water, is_lake)] = np.nan @@ -215,12 +216,14 @@ def plot_map( matplotlib.Axes """ if kind not in {"gradient", "elevation"}: - raise TypeError("Argument `kind` must be one of 'gradient' or 'elevation'") + raise TypeError( + "Argument `kind` must be one of 'gradient' or 'elevation'") if values is None: values = self.preprocess() if ax is None: - ratio = (self.lats[1] - self.lats[0]) / (self.longs[1] - self.longs[0]) + ratio = (self.lats[1] - self.lats[0]) / \ + (self.longs[1] - self.longs[0]) _, ax = plt.subplots(figsize=(size_scale, size_scale * ratio)) x = np.arange(values.shape[1]) From aa247b07e967298b9a744a9babfc1ff4836118f7 Mon Sep 17 00:00:00 2001 From: chenghuzi Date: Thu, 19 Mar 2020 01:30:23 -0400 Subject: [PATCH 3/3] reformat code --- ridge_map/ridge_map.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ridge_map/ridge_map.py b/ridge_map/ridge_map.py index eb0559e..fd66caf 100644 --- a/ridge_map/ridge_map.py +++ b/ridge_map/ridge_map.py @@ -153,8 +153,7 @@ def preprocess( values = (values - np.min(values)) / (np.max(values) - np.min(values)) is_water = values < np.percentile(values, water_ntile) - is_lake = rank.gradient(img_as_ubyte( - values), square(3)) < lake_flatness + is_lake = rank.gradient(img_as_ubyte(values), square(3)) < lake_flatness values[nan_vals] = np.nan values[np.logical_or(is_water, is_lake)] = np.nan @@ -216,14 +215,12 @@ def plot_map( matplotlib.Axes """ if kind not in {"gradient", "elevation"}: - raise TypeError( - "Argument `kind` must be one of 'gradient' or 'elevation'") + raise TypeError("Argument `kind` must be one of 'gradient' or 'elevation'") if values is None: values = self.preprocess() if ax is None: - ratio = (self.lats[1] - self.lats[0]) / \ - (self.longs[1] - self.longs[0]) + ratio = (self.lats[1] - self.lats[0]) / (self.longs[1] - self.longs[0]) _, ax = plt.subplots(figsize=(size_scale, size_scale * ratio)) x = np.arange(values.shape[1])