From 8012a15206660cd7f3319634b359961f0561fd68 Mon Sep 17 00:00:00 2001 From: wiltbemj Date: Tue, 31 Dec 2024 09:52:37 -0700 Subject: [PATCH] Updates to supermage for latest kaipy and edge case in SME/SMR case --- kaipy/satcomp/scutils.py | 19 +++++++++++++------ kaipy/supermage.py | 16 +++++++++++----- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/kaipy/satcomp/scutils.py b/kaipy/satcomp/scutils.py index 14e6763..55f7504 100644 --- a/kaipy/satcomp/scutils.py +++ b/kaipy/satcomp/scutils.py @@ -563,6 +563,9 @@ def genSCXML(fdir, ftag, scid="sctrack_A", h5traj="sctrack_A.h5", numSegments=1) unitsChild = root.createElement("units") unitsChild.setAttribute("uid", "EARTH") chimpChild.appendChild(unitsChild) + domainChild = root.createElement("domain") + domainChild.setAttribute("dtype", "LFM") + chimpChild.appendChild(domainChild) trajChild = root.createElement("trajectory") trajChild.setAttribute("H5Traj", h5traj) trajChild.setAttribute("doSmooth", "F") @@ -571,6 +574,7 @@ def genSCXML(fdir, ftag, scid="sctrack_A", h5traj="sctrack_A.h5", numSegments=1) # outChild = root.createElement('output') # outChild.setAttribute('doTrc', "T") # chimpChild.appendChild(outChild) + print("numSegments: ", numSegments) if numSegments > 1: parInTimeChild = root.createElement("parintime") parInTimeChild.setAttribute("NumB", "%d" % numSegments) @@ -936,15 +940,18 @@ def genSatCompPbsScript(scId, fdir, cmd, account='P28100045'): #PBS -A %s #PBS -N %s #PBS -j oe -#PBS -q casper +#PBS -q main #PBS -l walltime=1:00:00 #PBS -l select=1:ncpus=1 """ moduleString = """module purge -module load git/2.22.0 intel/19.1.1 netcdf/4.8.1 impi/2019.7.217 -module load ncarcompilers/0.5.0 ncarenv/1.3 cmake/3.22.0 -module load ffmpeg/4.1.3 geos/3.10.1 conda/latest -conda activate /glade/p/hao/msphere/gamshare/kaiju-3.8 +module load ncarenv/23.06 +module load craype/2.7.20 +module load intel/2023.0.0 +module load ncarcompilers/1.0.0 # Must come after intel/2023.0.0 +module load hdf5/1.12.2 +module load cmake/3.26.3 +module load geos/3.9.1 # Must come after intel/2023.0.0 module list """ commandString = """cd %s @@ -981,7 +988,7 @@ def genSatCompLockScript(scId, fdir, account='P28100045'): #PBS -A %s #PBS -N %s #PBS -j oe -#PBS -q casper +#PBS -q main #PBS -l walltime=0:15:00 #PBS -l select=1:ncpus=1 """ diff --git a/kaipy/supermage.py b/kaipy/supermage.py index 3b621d2..22b5eb8 100644 --- a/kaipy/supermage.py +++ b/kaipy/supermage.py @@ -526,7 +526,7 @@ def InterpolateSimData(SIM, SM): - SMRbins: List of 4 bins using interpolated data (SMR00/06/12/18). - superSMRbins: List of 4 bins using all data (SMR00/06/12/18). """ - + print("Interpolating data!!!") # find limits of overlapping data starttimei = np.max([SIM['td'][0], SM['td'][0]]) endtimei = np.min([SIM['td'][-1], SM['td'][-1]]) @@ -574,10 +574,16 @@ def InterpolateSimData(SIM, SM): ##### Now to calculate indices ##### # calculate SME, SML, SMU ind = (SM['mlat'] >= 40) * (SM['mlat'] <= 80) # equivalent to SME/SMU/SML - Northonly = interp_dBn.T[ind].T - SMU_calc = np.max(Northonly, axis = 1) - SML_calc = np.min(Northonly, axis = 1) - SME_calc = SMU_calc - SML_calc + print(f'ind: {ind}') + if not np.any(ind): + SMU_calc = np.zeros_like(smalltd) + SML_calc = np.zeros_like(smalltd) + SME_calc = np.zeros_like(smalltd) + else: + Northonly = interp_dBn.T[ind].T + SMU_calc = np.max(Northonly, axis = 1) + SML_calc = np.min(Northonly, axis = 1) + SME_calc = SMU_calc - SML_calc # calculate SME indices with ALL points between 40 and 80 (supersupermag) ind = (SIM['mlat'] >= 40) * (SIM['mlat'] <= 80)