-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added ConfSoilMoisture.py and some edits in Variable.py and ilamblib.py #44
Draft
ypwong22
wants to merge
18
commits into
rubisco-sfa:master
Choose a base branch
from
ypwong22:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d423f5a
add soil moisture data; buggy
ypwong22 2552995
Relaxed NBPplot constraint to accept one model & >10 year difference
ypwong22 da6c8b0
blank plots bug
ypwong22 79c36dc
working now for one model
ypwong22 2e13bcc
speed up WIP
ypwong22 a57c713
confrontation buggy
ypwong22 cf2d457
default relationships working w/ several models
ypwong22 f59de76
un-edited ConfNBP
ypwong22 0d2314e
begin sensitivity addition
ypwong22 841fcda
trend & sensitivity WIP
ypwong22 925dade
added trend & sens, first trial
ypwong22 97e0222
sens & trend framework finished
ypwong22 85ff1e9
trend sensitivity WIP
ypwong22 adfe0ef
sensitivity working; need to tweak visuals
ypwong22 fa11b65
partialcorr done
ypwong22 a11db71
fixed dropdown scores
ypwong22 02d66d9
fixed rel scoring
ypwong22 80bf6a9
multimodel
ypwong22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -74,10 +74,11 @@ def InitializeModels(model_root,models=[],verbose=False,filter="",regex="",model | |
if log: logger.debug("[%s]" % mname,format_exc()) | ||
continue | ||
M.append(m) | ||
|
||
max_model_name_len = max(max_model_name_len,len(mname)) | ||
break | ||
M = sorted(M,key=lambda m: m.name.upper()) | ||
|
||
# assign unique colors | ||
clrs = il.GenerateDistinctColors(len(M)) | ||
for m in M: | ||
|
@@ -248,6 +249,68 @@ def MatchRelationshipConfrontation(C): | |
found = True | ||
return C | ||
|
||
def MatchSensitivityConfrontation(C): | ||
# YW | ||
"""Match sensitivity strings to confrontation longnames | ||
|
||
We allow for sensitivity maps to be studied by specifying the | ||
sensitivity longname in the configure file. This routine loops | ||
over all defined sensitivity maps and finds the matching | ||
confrontation. | ||
|
||
Parameters | ||
---------- | ||
C : list of ILAMB.Confrontation.Confrontation | ||
the confrontation list | ||
|
||
Returns | ||
------- | ||
C : list of ILAMB.Confrontation.Confrontation | ||
the same list with sensitivity maps linked to confrontations. | ||
""" | ||
for c in C: | ||
if not hasattr(c, "sensitivities"): continue | ||
if c.sensitivities is None: continue | ||
for i,longname in enumerate(c.sensitivities): | ||
found = False | ||
for cor in C: | ||
if longname.lower() == cor.longname.lower(): | ||
c.sensitivities[i] = cor | ||
found = True | ||
return C | ||
|
||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove these lines, thanks for noticing that the function isn't needed. It seems like I got rid of it at some point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
# YW: Appears to duplicate MatchRelationshipConfrontation | ||
def MatchConfrontation(C): | ||
""" """Match relationship strings to confrontation longnames | ||
|
||
We allow for relationships to be studied by specifying the | ||
confrontation longname in the configure file. This routine loops | ||
over all defined relationships and finds the matching | ||
confrontation. (NOTE: this really belongs inside the Scoreboard | ||
object) | ||
|
||
Parameters | ||
---------- | ||
C : list of ILAMB.Confrontation.Confrontation | ||
the confrontation list | ||
|
||
Returns | ||
------- | ||
C : list of ILAMB.Confrontation.Confrontation | ||
the same list with relationships linked to confrontations | ||
""" """ | ||
for c in C: | ||
if c.relationships is None: continue | ||
for i,longname in enumerate(c.relationships): | ||
found = False | ||
for cor in C: | ||
if longname.lower() == cor.longname.lower(): | ||
c.relationships[i] = cor | ||
found = True | ||
return C | ||
""" | ||
|
||
def FilterConfrontationList(C,match_list): | ||
"""Filter the confrontation list | ||
|
||
|
@@ -303,8 +366,8 @@ def BuildLocalWorkList(M,C,skip_cache=False): | |
for c in C: | ||
for m in M: | ||
if skip_cache: | ||
# if we want to skip we have to check that it is complete | ||
|
||
# if we want to skip we have to check that it is complete | ||
fname = os.path.join(c.output_path,"%s_%s.nc" % (c.name,m.name)) | ||
complete = False | ||
if os.path.isfile(fname): | ||
|
@@ -346,6 +409,7 @@ def BuildLocalWorkList(M,C,skip_cache=False): | |
|
||
return localW | ||
|
||
|
||
def WorkConfront(W,verbose=False,clean=False): | ||
"""Performs the confrontation analysis | ||
|
||
|
@@ -378,7 +442,7 @@ def WorkConfront(W,verbose=False,clean=False): | |
|
||
# try to run the confrontation | ||
try: | ||
t0 = time.time() | ||
t0 = time.time() | ||
c.confront(m) | ||
dt = time.time()-t0 | ||
proc[rank] += dt | ||
|
@@ -393,7 +457,8 @@ def WorkConfront(W,verbose=False,clean=False): | |
logger.debug("[%s][%s]\n%s" % (c.longname,m.name,format_exc())) | ||
if verbose: | ||
print((" {0:>%d} {1:<%d} %s%s%s" % (maxCL,maxML,FAIL,ex.__class__.__name__,ENDC)).format(c.longname,m.name)) | ||
|
||
|
||
|
||
def WorkPost(M,C,W,S,verbose=False,skip_plots=False): | ||
"""Performs the post-processing | ||
|
||
|
@@ -428,6 +493,9 @@ def WorkPost(M,C,W,S,verbose=False,skip_plots=False): | |
proc[rank] += dt | ||
if verbose: | ||
dt = datetime.timedelta(seconds=max(1,int(np.round(dt)))) | ||
print((" {0:>%d} {1:<%d} %sCompleted%s {2:>8}" % (maxCL,maxML,OK,ENDC)).format(c.longname,m.name,str(dt))) | ||
|
||
|
||
print((" {0:>%d} {1:<%d} %sCompleted%s {2:>8}" % (maxCL,maxML,OK,ENDC)).format(c.longname,m.name,str(dt))) | ||
sys.stdout.flush() | ||
except Exception as ex: | ||
|
@@ -438,7 +506,7 @@ def WorkPost(M,C,W,S,verbose=False,skip_plots=False): | |
sys.stdout.flush() | ||
|
||
sys.stdout.flush(); comm.Barrier() | ||
|
||
for i,c in enumerate(C): | ||
try: | ||
c.compositePlots() | ||
|
@@ -487,6 +555,7 @@ class MPIFileHandler(logging.FileHandler): | |
|
||
def _open(self): | ||
stream = MPI.File.Open( self.comm, self.baseFilename, self.mode ) | ||
|
||
stream.Set_atomicity(True) | ||
return stream | ||
|
||
|
@@ -611,6 +680,7 @@ if args.model_setup is None: | |
models_path=args.build_dir[0]) | ||
else: | ||
M = ParseModelSetup(args.model_setup[0],args.models,not args.quiet,filter=args.filter[0],models_path=args.build_dir[0]) | ||
|
||
if rank == 0 and not args.quiet: print("\nParsing config file %s...\n" % args.config[0]) | ||
S = Scoreboard(args.config[0], | ||
regions = args.regions, | ||
|
@@ -622,7 +692,10 @@ S = Scoreboard(args.config[0], | |
mem_per_pair = args.mem_per_pair, | ||
run_title = args.run_title, | ||
rmse_score_basis = args.rmse_score_basis) | ||
|
||
C = MatchRelationshipConfrontation(S.list()) | ||
C = MatchSensitivityConfrontation(C) | ||
|
||
if len(args.study_limits) == 2: | ||
args.study_limits[1] += 1 | ||
for c in C: c.study_limits = (np.asarray(args.study_limits)-1850)*365. | ||
|
@@ -662,6 +735,7 @@ if rank==0 and not args.quiet: print("\nRunning model-confrontation pairs...\n") | |
sys.stdout.flush(); comm.Barrier() | ||
|
||
W = BuildLocalWorkList(M,C,skip_cache=True) | ||
|
||
WorkConfront(W,not args.quiet,args.clean) | ||
|
||
sys.stdout.flush(); comm.Barrier() | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the
#YW
comments here. Your name will be associated with this PR and thus we will always know who to blame :DThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done