Skip to content
Snippets Groups Projects
Commit 09ba68ae authored by Etor Lucio Eceiza's avatar Etor Lucio Eceiza
Browse files

add: installation, simple tools for conversion and check

parent 7353d934
No related branches found
No related tags found
No related merge requests found
*.DS*
.vscode
.idea
.ipynb_checkpoints
*/.ipynb_checkpoints
*/*/.ipynb_checkpoints
.vscode
*.log
.idea*
conda_env/
**/*.sw[pco]
**/*.*.sw[pco]
**/.ipynb_checkpoints*
**/*.py[co]
**/*~
**/._README.md
**/*egg*
Makefile 0 → 100644
# makefile used for testing
#
#
ENV_NAME=era5-tables
.PHONY: all conda install test
all: install test
conda:
conda create -n $(ENV_NAME) python=3.11
install: conda
@# python3 -m pip install -e .[dev]
conda run -n $(ENV_NAME) python -m pip install -e .[dev]
check:
conda activate $(ENV_NAME); cfchecks $(file)
clean:
conda remove -n $(ENV_NAME) --all -y
lint:
mypy --install-types --non-interactive
black --check -t py311 -l 79 src
flake8 src/rechunk_data --count --max-complexity=15 --max-line-length=88 --statistics --doctests
\ No newline at end of file
setup.py 0 → 100644
from setuptools import setup, find_packages
setup(
name='era5-tables',
version='0.1',
packages=find_packages(where='src'),
package_dir={'': 'src'},
install_requires=[
'pandas>=2.0.0',
'openpyxl>=3.1.0',
'cfchecker>=4.1.0',
'netCDF4>=1.6.0',
'numpy>=1.20.0'
],
extras_require={
'dev': [
'pytest',
'mypy',
'black',
'flake8',
'ipython'
]
},
python_requires='>=3.9',
)
import pandas as pd
import json
import csv
from pathlib import Path
def excel_to_csv(excel_path, csv_path, sheet_name=0, field_separator="|"):
df = pd.read_excel(excel_path, sheet_name=sheet_name)
df.to_csv(csv_path, sep=field_separator, index=False)
return csv_path
def csv_to_json(csv_path, json_path):
with open(csv_path, encoding='utf-8') as csvf:
csv_reader = csv.DictReader(csvf)
data = [row for row in csv_reader]
with open(json_path, 'w', encoding='utf-8') as jsonf:
json.dump(data, jsonf, indent=2)
return json_path
import subprocess
import sys
def cf_check(nc_file):
try:
result = subprocess.run(['cfchecks', nc_file], capture_output=True, text=True, check=True)
print(result.stdout)
except subprocess.CalledProcessError as e:
print("CF checker error:", e.stderr, file=sys.stderr)
sys.exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment