diff --git a/ptype/callbacks.py b/ptype/callbacks.py index f19be40..cefd047 100644 --- a/ptype/callbacks.py +++ b/ptype/callbacks.py @@ -5,7 +5,7 @@ CSVLogger, EarlyStopping, ) -from evml.keras.models import calc_prob_uncertainty +from mlguess.keras.models import calc_prob_uncertainty from tensorflow.python.keras.callbacks import ReduceLROnPlateau from sklearn.metrics import precision_recall_fscore_support, roc_auc_score from hagelslag.evaluation.ProbabilityMetrics import DistributedROC diff --git a/ptype/models.py b/ptype/models.py index ddd5f13..e1efdaf 100644 --- a/ptype/models.py +++ b/ptype/models.py @@ -13,8 +13,8 @@ from imblearn.under_sampling import RandomUnderSampler from imblearn.tensorflow import balanced_batch_generator -from evml.keras.losses import DirichletEvidentialLoss -from evml.keras.callbacks import ReportEpoch +from mlguess.keras.losses import DirichletEvidentialLoss +from mlguess.keras.callbacks import ReportEpoch logger = logging.getLogger(__name__) diff --git a/ptype/qc.py b/ptype/qc.py index d8b88ad..6d9993d 100644 --- a/ptype/qc.py +++ b/ptype/qc.py @@ -8,7 +8,6 @@ import xarray as xr import metpy.calc from metpy.units import units -import pandas as pd import geopandas as gpd from shapely.geometry import Point import cartopy.io.shapereader as shpreader diff --git a/ptype/reliability.py b/ptype/reliability.py index 657adac..080de89 100644 --- a/ptype/reliability.py +++ b/ptype/reliability.py @@ -1,4 +1,3 @@ -import os import numpy as np import matplotlib.pyplot as plt diff --git a/ptype/seed.py b/ptype/seed.py index e53901a..6323c5d 100644 --- a/ptype/seed.py +++ b/ptype/seed.py @@ -4,14 +4,15 @@ import tensorflow as tf import torch + def seed_everything(seed=1234): random.seed(seed) os.environ['PYTHONHASHSEED'] = str(seed) np.random.seed(seed) tf.keras.utils.set_random_seed(1) tf.config.experimental.enable_op_determinism() - - + + def torch_seed_everything(seed=1234): random.seed(seed) os.environ['PYTHONHASHSEED'] = str(seed) @@ -19,4 +20,4 @@ def torch_seed_everything(seed=1234): torch.manual_seed(seed) torch.cuda.manual_seed(seed) torch.backends.cudnn.benchmark = True - torch.backends.cudnn.deterministic = True \ No newline at end of file + torch.backends.cudnn.deterministic = True \ No newline at end of file diff --git a/ptype/visualization_utils.py b/ptype/visualization_utils.py index 5f4d762..6071348 100644 --- a/ptype/visualization_utils.py +++ b/ptype/visualization_utils.py @@ -16,9 +16,8 @@ from cartopy import crs as ccrs from cartopy import feature as cfeature import imageio -from PIL import Image from pathlib import Path -from datetime import datetime, timedelta +from datetime import datetime import xarray as xr from scipy.ndimage.filters import gaussian_filter @@ -34,14 +33,17 @@ "okla":[39.0, 31.0, -90.0, -106.0]} # colors = {0:'lime', 1:'darkturquoise', 2:'red', 3:'black'} -colors = {0:'lime', 1:'dodgerblue', 2:'red', 3:'black'} +colors = {0: 'lime', 1: 'dodgerblue', 2: 'red', 3: 'black'} datapath = "/glade/p/cisl/aiml/ai2es/winter_ptypes/precip_rap/" -def ptype_map(datatype, starttime, endtime, gifname, imgsavepath="gif_images", gifsavepath="gifs", coords="na", duration=0.5): + +def ptype_map(datatype, starttime, endtime, gifname, + imgsavepath="gif_images", gifsavepath="gifs", coords="na", + duration=0.5): """ Create and save GIF of P-Type data over specific CONUS region and time range. - - :param datatype: + + :param datatype: :param starttime: :param endtime: :param gifname: @@ -55,7 +57,7 @@ def ptype_map(datatype, starttime, endtime, gifname, imgsavepath="gif_images", g enddate = datetime.strptime(endtime, "%Y%m%d %H:%M:%S") time_range = pd.date_range(startdate, enddate, freq="h").strftime("%Y%m%d %H:%M:%S") coords = coord_dict[coords] - + # Account for differences between mPING and ASOS. if datatype == "mping": if enddate >= datetime.strptime("20180101", "%Y%m%d"):