Skip to content

Commit

Permalink
black and isort revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
lee1043 committed Nov 4, 2021
1 parent 7ca80ff commit b0c4b61
Show file tree
Hide file tree
Showing 88 changed files with 762 additions and 589 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: "docs|node_modules|migrations|.git|.tox|sample_setups/jsons|tests/deprecated"
exclude: "docs|node_modules|migrations|.git|.tox|sample_setups/(external-setups|jsons)|tests/deprecated"
default_stages: [commit]
fail_fast: true

Expand Down
1 change: 1 addition & 0 deletions cmec/scripts/climatologies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import subprocess
import sys

import genutil


Expand Down
1 change: 1 addition & 0 deletions cmec/scripts/pmp_param_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import subprocess
import sys

import genutil
from climatologies import make_climatologies

Expand Down
2 changes: 1 addition & 1 deletion doc/jupyter/Demo/download_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def generate_parameter_files(demo_data_directory, demo_output_directory, filenam
if __name__ == "__main__":
"""Perform the same actions as Demo 0 notebook: Get the tutorial file list,
download the sample data, and generate the parameter files."""
import requests
import cdat_info
import requests

r = requests.get("https://pcmdiweb.llnl.gov/pss/pmpdata/pmp_tutorial_files.txt")
with open("data_files.txt", "wb") as f:
Expand Down
57 changes: 35 additions & 22 deletions doc/misc/simple_json_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,65 @@
import json

# READ JSON FILE CONTAING RESULTS FROM ONE MODEL
onemod_file = '/work/gleckler1/processed_data/metrics_package/' +\
'metrics_results/sampletest1/tas_2.5x2.5_regrid2_linear_metrics.json'
onemod_file = (
"/work/gleckler1/processed_data/metrics_package/"
+ "metrics_results/sampletest1/tas_2.5x2.5_regrid2_linear_metrics.json"
)

# READ JSON FILE CONTAING RESULTS FROM A CMIP DATABASE
cmipmods_file = '/work/gleckler1/processed_data/metrics_package/' +\
'metrics_results/cmip5_test/tas_2.5x2.5_regrid2_linear_metrics.json'
cmipmods_file = (
"/work/gleckler1/processed_data/metrics_package/"
+ "metrics_results/cmip5_test/tas_2.5x2.5_regrid2_linear_metrics.json"
)

# HOW TO LOAD A DICTIONARY INTO MEMORY FROM A JSON FILE

onemod_dic = json.load(open(onemod_file, 'rb'))
cmipmods_dic = json.load(open(cmipmods_file, 'rb'))
onemod_dic = json.load(open(onemod_file, "rb"))
cmipmods_dic = json.load(open(cmipmods_file, "rb"))


# PCMDI METRICS PACKAGE STORES INFORMATION IN NESTED DICTIONARIES. WE
# START WITH SIMPLE EXAMPLE.

print(' ')
print(" ")

test1 = onemod_dic['CCSM4']['default']['r1i1p1']['global']['rms_xy_ann_GLB']
test1 = onemod_dic["CCSM4"]["default"]["r1i1p1"]["global"]["rms_xy_ann_GLB"]

print('A sample result: ', test1)
print(' ')
print('Using "type" function to show conversion of test1 from unicode to real via float(test1) ',
type(test1), ' ', type(float(test1)))
print("A sample result: ", test1)
print(" ")
print(
'Using "type" function to show conversion of test1 from unicode to real via float(test1) ',
type(test1),
" ",
type(float(test1)),
)


print(' ')
print('Showing the source of the "default" observations: ', onemod_dic['CCSM4']['default']['source'])
print(" ")
print(
'Showing the source of the "default" observations: ',
onemod_dic["CCSM4"]["default"]["source"],
)

# FOR BASIC INFORMATION ON PYTHON DICTIONARIES SEE
# http://www.tutorialspoint.com/python/python_dictionary.htm

KeyList = onemod_dic.keys()
print(' ')
print('Keys from from dictionary read from json file ', KeyList)
print(' ')
print(" ")
print("Keys from from dictionary read from json file ", KeyList)
print(" ")
#
KeyList = [s.encode('utf-8')
for s in KeyList] # CHANGE FROM UNICODE TO BYTE STRINGS
KeyList = [s.encode("utf-8") for s in KeyList] # CHANGE FROM UNICODE TO BYTE STRINGS

print('Keys from from dictionary read from json file after unicode converted to strings ', KeyList)
print(
"Keys from from dictionary read from json file after unicode converted to strings ",
KeyList,
)
KeyList

print(' ')
print(" ")

print('Getting a list from all models in the CMIP database: ', cmipmods_dic.keys())
print("Getting a list from all models in the CMIP database: ", cmipmods_dic.keys())

# NOTE CONVERTING FROM UNICODE TO BYTE STRINGS IS NOT NECESSARY WHEN
# ACCESSING KEYS IN DICTIONARIES. EITHER UNICODE OR ASCII CAN BE USED.
2 changes: 1 addition & 1 deletion pcmdi_metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
plog.setLevel(LOG_LEVEL)
from . import io # noqa
from . import pcmdi # noqa
from .version import __version__, __git_sha1__, __git_tag_describe__ # noqa
from .version import __git_sha1__, __git_tag_describe__, __version__ # noqa
5 changes: 3 additions & 2 deletions pcmdi_metrics/devel/example_dev/scripts/example_dev1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python
from pcmdi_metrics.example_dev import example
import sys
import argparse
import sys

from pcmdi_metrics.example_dev import example

parser = argparse.ArgumentParser(description="Adds two integers")
parser.add_argument("numbers", nargs=2, type=float, help="two numbers to add")
Expand Down
7 changes: 4 additions & 3 deletions pcmdi_metrics/devel/monsoon_wang/graphics/SeabarChart_mpl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
import matplotlib.pyplot as PLT
import sys
import pdb
import sys

import matplotlib.pyplot as PLT
import numpy as np


class BarChart(object):
Expand Down
1 change: 1 addition & 0 deletions pcmdi_metrics/devel/monsoon_wang/graphics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from taylorDiagram import TaylorDiagram # noqa

from .SeabarChart_mpl import BarChart # noqa
Loading

0 comments on commit b0c4b61

Please sign in to comment.