-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build for pypi and conda, vers 0.2.11
- Loading branch information
Showing
14 changed files
with
3,879 additions
and
487 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,10 @@ | |
''' | ||
|
||
from __future__ import absolute_import | ||
|
||
from . import configure | ||
configure.check_config() | ||
|
||
from .core import * | ||
from . import fplt | ||
from . import unit | ||
|
@@ -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]>'] | ||
|
||
|
@@ -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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.