Skip to content

Commit

Permalink
add ee files
Browse files Browse the repository at this point in the history
  • Loading branch information
MAfarrag committed Sep 21, 2022
1 parent cb94ab8 commit 5ddce9a
Show file tree
Hide file tree
Showing 30 changed files with 661 additions and 223 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
repo_token: hxJrvjqiH2xBI7eit7BAb7FidH0LeYpGq
service_name: github-action

6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand All @@ -61,7 +61,7 @@ jobs:
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage1.xml,./coverage2.xml
directory: ./coverage/reports/
directory: ./coverage/reports/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ build_artifacts
mo_*
conda/
/examples/data/ecmwf/daily/*
.idea/*
poetry.lock
pyproject.toml
98 changes: 53 additions & 45 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
# - id: check-yaml
# name: "[yaml - check] validate yaml"
- id: end-of-file-fixer
name: "[py - check] validate yaml"
- id: trailing-whitespace
name: "[file - format] trim trailing whitespace"
args: [ --markdown-linebreak-ext=md ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
name: "[py - check] validate yaml"
- id: trailing-whitespace
name: "[file - format] trim trailing whitespace"
args: [ --markdown-linebreak-ext=md ]
- id: check-added-large-files
name: "[file - check] large file"
args: [ --maxkb=5000 ]
Expand Down Expand Up @@ -37,41 +35,51 @@ repos:
--no-sort-keys ]
- id: requirements-txt-fixer
name: "[reqs - format] fix requirements.txt"
- id: check-yaml
name: "[yaml - check] validate yaml"
- repo: https://github.com/PyCQA/docformatter
rev: v1.4
hooks:
- id: docformatter
name: "[py - format] docformatter"
args: [ -i, --wrap-summaries, "0" ]

# - repo: https://github.com/PyCQA/docformatter
# rev: v1.4
# hooks:
# - id: docformatter
## name: "[py - format] docformatter"
## args: [ -i, --wrap-summaries, "0" ]
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
name: "[py - check] pydocstyle"
files: ^Hapi/

# - repo: https://github.com/PyCQA/pydocstyle
# rev: 6.1.1
# hooks:
# - id: pydocstyle
# name: "[py - check] pydocstyle"
# files: ^Hapi/
# TODO : uncheck later and fix all the problems of line too long
#- repo: https://gitlab.com/pycqa/flake8
# rev: 3.8.4
# hooks:
# - id: flake8
# name: "[py - check] flake8"
# language_version: python3.8
# TODO : this hook does not fix the files
#- repo: https://github.com/psf/black
# rev: 19.3b0
# hooks:
# - id: black
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0
hooks:
- id: isort
name: "[py - format] isort"
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
name: "[py - check] flake8"
language_version: python3.9
exclude: ^(examples/|tests/)

#- repo: https://github.com/ambv/black
# rev: 20.8b1
# hooks:
# - id: black
# name: "[py - format] black"
# language_version: python3.8
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0
hooks:
- id: isort
name: "[py - format] isort"
- repo: https://github.com/ambv/black
rev: 22.8.0
hooks:
- id: black
name: "[py - format] black"
language_version: python3.9

- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ earthobserve

Main Features
-------------
-
-


Future work
-------------
-
-



Expand Down
4 changes: 2 additions & 2 deletions clone.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"message": "Must have push access to repository",
"documentation_url": "https://docs.github.com/rest/reference/repos#get-repository-clones"
"message": "Must have push access to repository",
"documentation_url": "https://docs.github.com/rest/reference/repos#get-repository-clones"
}
19 changes: 9 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

# General information about the project.
project = u"pyramids"
author = "Mostafa Farrag"

# copyright = u"2013-2019, "


import os
import sys

# import sphinx_rtd_theme

# General information about the project.
project = "pyramids"
author = "Mostafa Farrag"

# copyright = u"2013-2019, "

html_theme = "sphinxdoc"
# html_theme = "agogo"
html_theme_path = ["."]
Expand Down Expand Up @@ -207,7 +206,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
("index", "pyramids.tex", u"pyramids Documentation", u"Mostafa Farrag", "report")
("index", "pyramids.tex", "pyramids Documentation", "Mostafa Farrag", "report")
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -250,8 +249,8 @@
(
"index",
"pyramids",
u"pyramids Documentation",
u"Mostafa Farrag",
"pyramids Documentation",
"Mostafa Farrag",
"pyramids",
"One line description of project.",
"Miscellaneous",
Expand Down
18 changes: 10 additions & 8 deletions earth2observe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# documentation format
__author__ = "Mostafa Farrag"
__email__ = '[email protected]'
__email__ = "[email protected]"
__docformat__ = "restructuredtext"

# Let users know if they're missing any of our hard dependencies
Expand All @@ -25,30 +25,32 @@
__import__(dependency)
except ImportError as e:
missing_dependencies.append(dependency)
print(e)

if missing_dependencies:
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))

def configuration(parent_package='',top_path=None):

def configuration(parent_package="", top_path=None):

from numpy.distutils.misc_util import Configuration

config = Configuration(None,parent_package,top_path)
config = Configuration(None, parent_package, top_path)
config.set_options(
ignore_setup_xxx_py=True,
assume_default_configuration=True,
delegate_options_to_subpackages=True,
quiet=True,
)

config.add_subpackage('gee')
config.add_subpackage("gee")
return config


import earth2observe.chirps as chirps
import earth2observe.ecmwf as ecmwf
import earth2observe.gee as gee
import earth2observe.utils as utils
# import earth2observe.chirps as chirps
# import earth2observe.ecmwf as ecmwf
# import earth2observe.gee as gee
# import earth2observe.utils as utils

__doc__ = """
earth2observe - remote sensing package
Expand Down
58 changes: 30 additions & 28 deletions earth2observe/chirps.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import os
import datetime as dt
import os
from ftplib import FTP

import numpy as np
import pandas as pd
from ftplib import FTP
from joblib import Parallel, delayed
from osgeo import gdal
from pyramids.raster import Raster
from earth2observe.utils import print_progress_bar, extractFromGZ

from earth2observe.utils import extractFromGZ, print_progress_bar


class CHIRPS:
"""
CHIRPS
"""
"""CHIRPS."""

def __init__(
self,
start: str="",
end: str="",
lat_lim: list=[],
lon_lim: list=[],
time: str="daily",
path: str="",
fmt: str="%Y-%m-%d",
self,
start: str = "",
end: str = "",
lat_lim: list = [],
lon_lim: list = [],
time: str = "daily",
path: str = "",
fmt: str = "%Y-%m-%d",
):
"""CHIRPS.
Expand Down Expand Up @@ -52,7 +53,9 @@ def __init__(
self.output_folder = os.path.join(path, "Precipitation", "CHIRPS", "Daily")
elif time == "monthly":
self.time_freq = "MS"
self.output_folder = os.path.join(path, "Precipitation", "CHIRPS", "Monthly")
self.output_folder = os.path.join(
path, "Precipitation", "CHIRPS", "Monthly"
)
else:
raise KeyError("The input time interval is not supported")
self.time = time
Expand Down Expand Up @@ -94,16 +97,17 @@ def __init__(
self.lon_lim = lon_lim
# Define IDs
self.yID = 2000 - np.int16(
np.array([np.ceil((lat_lim[1] + 50) * 20), np.floor((lat_lim[0] + 50) * 20)])
np.array(
[np.ceil((lat_lim[1] + 50) * 20), np.floor((lat_lim[0] + 50) * 20)]
)
)
self.xID = np.int16(
np.array(
[np.floor((lon_lim[0] + 180) * 20), np.ceil((lon_lim[1] + 180) * 20)]
)
)


def Download(self, progress_bar: bool=True, cores=None):
def Download(self, progress_bar: bool = True, cores=None):
"""Download.
Download method downloads CHIRPS data
Expand Down Expand Up @@ -162,7 +166,6 @@ def Download(self, progress_bar: bool=True, cores=None):
)
return results


@staticmethod
def RetrieveData(Date, args):
"""RetrieveData.
Expand Down Expand Up @@ -198,8 +201,8 @@ def RetrieveData(Date, args):
# Define FTP path to directory
if TimeCase == "daily":
pathFTP = (
"pub/org/chg/products/CHIRPS-2.0/global_daily/tifs/p05/%s/"
% Date.strftime("%Y")
"pub/org/chg/products/CHIRPS-2.0/global_daily/tifs/p05/%s/"
% Date.strftime("%Y")
)
elif TimeCase == "monthly":
pathFTP = "pub/org/chg/products/CHIRPS-2.0/global_monthly/tifs/"
Expand Down Expand Up @@ -263,7 +266,7 @@ def RetrieveData(Date, args):
dataset, NoDataValue = Raster.getRasterData(src)

# clip dataset to the given extent
data = dataset[yID[0]: yID[1], xID[0]: xID[1]]
data = dataset[yID[0] : yID[1], xID[0] : xID[1]]
# replace -ve values with -9999
data[data < 0] = -9999

Expand All @@ -281,14 +284,13 @@ def RetrieveData(Date, args):
os.remove(outfilename)

except PermissionError:
print("The file covering the whole world could not be deleted please delete it after the download ends")
print(
"The file covering the whole world could not be deleted please delete it after the download ends"
)
return True


def ListAttributes(self):
"""
Print Attributes List
"""
"""Print Attributes List."""

print("\n")
print(
Expand All @@ -300,4 +302,4 @@ def ListAttributes(self):
if key != "name":
print(str(key) + " : " + repr(self.__dict__[key]))

print("\n")
print("\n")
Loading

0 comments on commit 5ddce9a

Please sign in to comment.