Skip to content

Commit

Permalink
cv update
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfiex committed Jul 29, 2024
1 parent 86fda51 commit 5fd789d
Show file tree
Hide file tree
Showing 7 changed files with 2,845 additions and 534 deletions.
3,063 changes: 2,715 additions & 348 deletions cmipld/cvs/CV.json

Large diffs are not rendered by default.

35 changes: 19 additions & 16 deletions cmipld/cvs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def main():
##################################

# mip entries
for key in 'source-type frequency realm grid-label'.split():
for key in 'source-type frequency realm grid-label nominal-resolution'.split():

# run the frame.
frame = get_frame('mip-cmor-tables',key)
Expand All @@ -41,8 +41,6 @@ async def main():
add_new = await process('mip-cmor-tables',key,data)

CV[key.replace('-','_')] = add_new

# nominal_resolution


##################################
Expand All @@ -51,9 +49,11 @@ async def main():


frame = get_frame('cmip6plus','descriptors')
data = Frame(latest,frame,False)
data.print
data = Frame(latest,frame,False).clean(['rmld','missing','untag','lower'])

add_new = await process('cmip6plus','descriptors',data,clean=['rmld','missing','untag','lower'])


CV.update(add_new)

# ##################################
Expand All @@ -65,8 +65,6 @@ async def main():

# run the frame.
frame = get_frame('cmip6plus',key)

print('\n\n---',key)
# get results using frame
data = Frame(latest,frame)

Expand All @@ -75,25 +73,30 @@ async def main():
CV[key.replace('-','_')] = add_new


print('concluding')
##################################
### fix the file #####
##################################

CV['version_metadata'] = dict(
CVs = dict(
version = os.system('git describe --tags --abbrev=0').read().strip(),
modified = datetime.now().date().isoformat(),
gitcommit = os.system('git rev-parse HEAD').read().strip(),
gitbranch = os.system('git rev-parse --abbrev-ref HEAD').read().strip(),
)
future = 'miptables, checksum, etc'
)
CV['version_metadata'] = {
"file_modified" : datetime.now().date().isoformat(),
"CV": {
"version": os.popen('git describe --tags --abbrev=0').read().strip() or 'version tag read from repo running - currently not in it. ',
"git_commit":os.popen('git rev-parse HEAD').read().strip(),
"gitbranch" : os.popen('git rev-parse --abbrev-ref HEAD').read().strip() } ,
"future": 'miptables, checksum, etc'}



CV = OrderedDict(sorted((k, (v)) for k, v in CV.items()))

# import pprint
# pprint.pprint(CV)
# print(CV)
with open('CV.json','w') as f:
json.dump(dict(CV = CV),f,indent=4)
print('written to ',f.name )




Expand Down
25 changes: 19 additions & 6 deletions cmipld/cvs/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
def name_description(data,key='name',value='description'):
return dict([(x[key],x[value]) for x in data])

def key_only(data,key='name'):
return list(set([x[key] for x in data]))
def key_only(data,key='name',default='missing'):
return sorted(list(set([x.get(key,default) for x in data])))


##################################
Expand Down Expand Up @@ -36,12 +36,19 @@ def cmip6plus_descriptors (data):
for i in data['index']:
if isinstance(data['index'][i],str):
data['index'][i] = [data['index'][i]]

for i in 'tracking_id license'.split():
if isinstance(data[i],str):
data[i] = [data[i]]


data.update(data['index'])
del data['index']
data['DRS'] = data['drs']
data['Conventions'] = data['conventions']
data['mip_era'] = data['mip_era']['name']

del data['drs'], data['conventions']
del data['drs'], data['conventions'], data['@context']
return data

def cmip6plus_activity_id (data):
Expand Down Expand Up @@ -93,20 +100,26 @@ def cmip6plus_sub_experiment_id (data):


def cmip6plus_experiment_id (data):
print(data)
eid = OrderedDict()
for e in sorted(data,key=lambda x: x['experiment_id']):

for i in ['additional_allowed','required']:
if isinstance(e['model_components'][i],str):
e['model_components'][i] =[e['model_components'][i]]

e['model_components'][i] = [e['model_components'][i]]
e[f'{i}_model_components'] = e['model_components'][i]

del e['model_components']

# to list
e['activity_id'] = [e['activity_id']]

for i in e['parent']:
e['parent_'+i] = [e['parent'][i]]



e['sub_experiment_id'] = e ['sub_experiment_id'].get('name','missing')

del e['parent']

eid[e['experiment_id']] = e
Expand Down
234 changes: 79 additions & 155 deletions cmipld/cvs/review.ipynb

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion cmipld/frame_ld/examples/cmip6plus/descriptors.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{
"@id": "cmip6plus:core/descriptors",
"@context": {
"@extend": true
"@extend": true,

"core:mip-era": {
"@context": {
"@vocab": "mip:"
}
}
},
"@type": "mip:core-descriptors",
"core:mip-era": {

"@vocab": "mip:",
"mip:name": {},
"@explicit": true
},
Expand Down
6 changes: 2 additions & 4 deletions cmipld/frame_ld/examples/cmip6plus/experiment-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@extend": true
}
},
"@extend": true,
"experiment-id:sub-experiment-id": {
"@context": {
"@extend": true
Expand All @@ -29,10 +30,7 @@
"@explicit": true
}
},
"experiment-id:sub-experiment-id": {
"sub-experiment-id:name": {},
"@explicit": true
},

"experiment-id:parent":{
"@embed":"@always"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"@type":
"mip:model-component",
"mip:resolution",

"model-component:nominal-resolution": {

},
"resolution:name":"",
"@explicit": true
}

0 comments on commit 5fd789d

Please sign in to comment.