Skip to content

Commit

Permalink
build for pypi and conda, vers 0.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrdn committed Jun 29, 2021
1 parent 49d9d54 commit 5b62294
Show file tree
Hide file tree
Showing 14 changed files with 3,879 additions and 487 deletions.
8 changes: 4 additions & 4 deletions bgcArgoDMQC.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: bgcArgoDMQC
Version: 0.2.10
Version: 0.2.11
Summary: A python library for quality control of BGC-Argo data
Home-page: https://github.com/ArgoCanada/bgcArgoDMQC
Author-email: [email protected]
Expand Down Expand Up @@ -45,10 +45,10 @@ Description: # Argo Canada BGC Quality Control
## bgcArgo dependencies

- Must run on `python3.4` or higher, not supported on `python2.x` (uses [pathlib](https://docs.python.org/3/library/pathlib.html), introduced in python version 3.4)
- TEOS-10 package [gsw](https://teos-10.github.io/GSW-Python/), but will also work with the [seawater](https://pypi.org/project/seawater/) package, though it is deprecated in favor of gsw
- TEOS-10 package [gsw](https://teos-10.github.io/GSW-Python/)
- [netCDF4](https://pypi.org/project/netCDF4/) module for `.nc` files
- [pandas](https://pandas.pydata.org/) is required (and highly recommended for all your data science needs!)
- [seaborn](https://seaborn.pydata.org/) is recommended but not required, through there will be some reduced (non-essential) functionality
- [pandas](https://pandas.pydata.org/) is required
- [seaborn](https://seaborn.pydata.org/)
- [cmocean](https://matplotlib.org/cmocean/) is also recommended for nicer plots, but not required

## basic functionality
Expand Down
2 changes: 2 additions & 0 deletions bgcArgoDMQC.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ README.md
requirements.txt
setup.py
bgcArgoDMQC/__init__.py
bgcArgoDMQC/configure.py
bgcArgoDMQC/core.py
bgcArgoDMQC/diagnostic.py
bgcArgoDMQC/fplt.py
bgcArgoDMQC/interp.py
bgcArgoDMQC/io.py
bgcArgoDMQC/lut.py
bgcArgoDMQC/unit.py
bgcArgoDMQC/util.py
bgcArgoDMQC.egg-info/PKG-INFO
Expand Down
4 changes: 2 additions & 2 deletions bgcArgoDMQC/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "bgcArgoDMQC" %}
{% set version = "0.2.10" %}
{% set version = "0.2.11" %}


package:
Expand All @@ -8,7 +8,7 @@ package:

source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/bgcArgoDMQC-{{ version }}.tar.gz
sha256: ba2047e3291b180a6b0749e83575c88eacaafe8e05d6281e4340138805857364
sha256: 9e69abd3e75c3e673c7a31ace9b3e72401ea5b478475dba211705936562fab53

build:
number: 0
Expand Down
14 changes: 13 additions & 1 deletion build/lib/bgcArgoDMQC/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
'''

from __future__ import absolute_import

from . import configure
configure.check_config()

from .core import *
from . import fplt
from . import unit
Expand All @@ -36,7 +40,7 @@
from . import interp
from . import diagnostic

__all__ = ['fplt', 'unit', 'util', 'io', 'interp', 'diagnostic']
__all__ = ['fplt', 'unit', 'util', 'io', 'interp', 'diagnostic', 'configure']

__author__ = ['Christopher Gordon <[email protected]>']

Expand All @@ -45,3 +49,11 @@
# check age of index file, or if it exists
if not io.index_exists():
io.update_index()

# get a dict with with config info
config = configure.read_config()
# set the directories within the config file
dir_config = {k:v for k,v in config.items() if k in ['argo_path', 'woa_path', 'ncep_path']}
set_dirs(**dir_config)

from .core import *
86 changes: 86 additions & 0 deletions build/lib/bgcArgoDMQC/configure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
from pathlib import Path

global config_file
pkg_path = Path(__file__).parent.absolute()
config_file = pkg_path / '.config'

def check_config():
'''
Check that configuration file exists, and if not, create a blank one.
Having a blank file exist eases throwing any FileNotFoundError's, but
if the config is blank then still no configuration is performed.
'''
# make sure its there, even as an empty file, eases handling of FileNotFoundError's
if not config_file.exists():
config_file.touch()

def read_config():
'''
Read in permanently stored configuration information for locations of
Argo, NCEP, or WOA data.
'''
# dict object to load values into
config_dict = dict()
# loop through the config file - if there are no lines, will return an
# empty dict, which is fine/right
with open(config_file) as f:
for line in f:
llist = line.split('=')
key = llist[0]
val = llist[1].strip()
config_dict[key] = val

return config_dict

def reset_config():
'''
Permanently erase .config data, replace with empty file.
'''
config_file.unlink()
config_file.touch()

def configure(argo_path=None, ncep_path=None, woa_path=None, operator_name=None, operator_orcid=None, default_url=None):
'''
Set up locations for Argo, NCEP, and/or WOA data on local machine.
'''
# if they aren't already paths, make them paths, then make posix
if argo_path is not None:
argo_path = Path(argo_path).as_posix()
if ncep_path is not None:
ncep_path = Path(ncep_path).as_posix()
if woa_path is not None:
woa_path = Path(woa_path).as_posix()

# existing and new configuration info
existing_config = read_config()
new_config = dict(
argo_path=argo_path, ncep_path=ncep_path, woa_path=woa_path,
operator_name=operator_name, operator_orcid=operator_orcid,
default_url=default_url
)

# get rid of None values
clean_new_config = {k: v for k, v in new_config.items() if v is not None}

# config info already in .config file that should be kept
keep_config = set(existing_config.keys()) - set(clean_new_config.keys())

# config info that either exists in .config and should be overwritten, or is new to .config
overwritten_config = set(existing_config.keys()).intersection(set(clean_new_config.keys()))
add_config = set(clean_new_config.keys()) - set(existing_config.keys())
write_config = overwritten_config | add_config

final_config = dict()
for k in keep_config:
final_config[k] = existing_config[k]
for k in write_config:
final_config[k] = clean_new_config[k]

# write the .config file anew
with open(config_file, 'w') as f:
i = 0
for k, v in final_config.items():
if i > 0:
f.write('\n')
f.write('{}={}'.format(k, v))
i += 1
Loading

0 comments on commit 5b62294

Please sign in to comment.