Skip to content

Commit 174eed0

Browse files
committed
updating templates to the new EMD specification
1 parent 032343a commit 174eed0

20 files changed

+1734
-355
lines changed

.github/.DS_Store

0 Bytes
Binary file not shown.

.github/GEN_ISSUE_TEMPLATE/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ GEN_ISSUE_TEMPLATE/
4141

4242
| Template | Creates | Dependencies | Files |
4343
|----------|---------|--------------|-------|
44-
| **grid_cells_and_subgrid** | Grid cells + Subgrids (2-3 entities) | None | .csv, .py, .json |
44+
| **grid_cell_and_subgrid** | Grid cells + Subgrids (2-3 entities) | None | .csv, .py, .json |
4545
| **horizontal_computational_grid** | H-Grid (1 entity) | Subgrids | .csv, .py, .json |
4646
| **vertical_computational_grid** | V-Grid (1 entity) | None | .csv, .py, .json |
4747
| **model_component** | Component + Config (2 entities) | Grids | .csv, .py, .json |
@@ -54,7 +54,7 @@ GEN_ISSUE_TEMPLATE/
5454
### Phase 1: Grids (3 issues per config)
5555

5656
```
57-
1. grid_cells_and_subgrid → s100, s101
57+
1. grid_cell_and_subgrid → s100, s101
5858
5959
2. horizontal_computational_grid (refs s100, s101) → c100
6060
↓ (parallel)
@@ -190,7 +190,7 @@ DATA = {
190190
```json
191191
{
192192
"grouping": {
193-
"Grid Registration": ["grid_cells_and_subgrid", "horizontal_computational_grid", "vertical_computational_grid"],
193+
"Grid Registration": ["grid_cell_and_subgrid", "horizontal_computational_grid", "vertical_computational_grid"],
194194
"Component Registration": ["model_component"],
195195
"Model Registration": ["model_family", "model"]
196196
},
@@ -222,7 +222,7 @@ Workflow: `.github/workflows/issue-templates.yml`
222222
## Template Files
223223

224224
### Active Templates (7)
225-
grid_cells_and_subgrid (.csv, .py, .json)
225+
grid_cell_and_subgrid (.csv, .py, .json)
226226
✅ horizontal_computational_grid (.csv, .py, .json)
227227
✅ vertical_computational_grid (.csv, .py, .json)
228228
✅ model_component (.csv, .py, .json)

.github/GEN_ISSUE_TEMPLATE/_config.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"grouping": {
33
"Grid Registration": [
4-
"grid_cells_and_subgrid",
4+
"grid_cell_and_subgrid",
55
"horizontal_computational_grid",
66
"vertical_computational_grid"
77
],
@@ -13,12 +13,11 @@
1313
"model"
1414
],
1515
"Issues & Discussion": [
16-
"discussion",
1716
"general_issue"
1817
]
1918
},
2019
"template_order": [
21-
"grid_cells_and_subgrid",
20+
"grid_cell_and_subgrid",
2221
"horizontal_computational_grid",
2322
"vertical_computational_grid",
2423
"model_component",
Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,14 @@
11
# General Issue Template Configuration
22

33
TEMPLATE_CONFIG = {
4-
'name': 'General Issue',
5-
'description': 'Report a general issue, bug, or request',
6-
'title': 'Issue: <Brief description here>',
7-
'labels': ['emd', 'general'],
8-
'issue_category': 'general'
4+
'name': 'General Issue or Question',
5+
'description': 'Report issues, ask questions, or suggest improvements',
6+
'title': '[EMD] General Issue:',
7+
'labels': ['question'],
8+
'issue_category': 'general_issue'
99
}
1010

11-
# Data for this template
11+
# Data for this template
1212
DATA = {
13-
'issue_type_options': [
14-
'Bug Report',
15-
'Feature Request',
16-
'Documentation Issue',
17-
'CV Term Request',
18-
'Process Improvement',
19-
'Question',
20-
'Other'
21-
],
22-
'affected_areas_options': [
23-
'Model Registration',
24-
'Model Component Registration',
25-
'Model Family Registration',
26-
'Grid Definitions',
27-
'References',
28-
'Documentation',
29-
'GitHub Actions/Workflows',
30-
'Issue Templates',
31-
'Validation Scripts',
32-
'General Repository Structure',
33-
'All/Multiple Areas'
34-
],
35-
'priority_options': [
36-
'Critical - Blocking work',
37-
'High - Important issue',
38-
'Medium - Should be addressed',
39-
'Low - Nice to fix'
40-
],
41-
'help_needed_options': [
42-
'I can work on this myself',
43-
'I need help implementing a solution',
44-
"I'm just reporting this issue"
45-
]
13+
'issue_kind': ['New', 'Modify']
4614
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
field_order,field_type,field_id,label,description,data_source,required,placeholder,options_type,default_value
2+
1,markdown,header,,"## Grid Cell and Subgrid Registration\n\nOne form creates TWO linked entities:\n- **horizontal_grid_cells**: Physical properties (resolution, type, region)\n- **horizontal_subgrid**: Variable types using these cells\n\nDescriptions and IDs auto-generated. Result: Subgrid ID (s###) for use in h-grid registration.",none,false,,,
3+
2,markdown,cells_header,,"## Horizontal Grid Cells",none,false,,,
4+
3,dropdown,grid_type,Grid Type,Cell distribution pattern.,grid_type,true,,list_with_na,0
5+
4,dropdown,grid_mapping,Coordinate System,Reference system.,grid_mapping,true,,list_with_na,0
6+
5,multi-select,region,Region,Geographic coverage.,region,true,,list,
7+
6,dropdown,temporal_refinement,Temporal Refinement,Time variation.,temporal_refinement,true,,list_with_na,0
8+
7,input,x_resolution,X Resolution,X cell size (omit if varies >25%).,none,false,"e.g., 1.25",,
9+
8,input,y_resolution,Y Resolution,Y cell size (omit if varies >25%).,none,false,"e.g., 0.9",,
10+
9,dropdown,units,Units,Resolution units.,units,false,,list_with_na,0
11+
10,input,n_cells,Number of Cells,Total cells.,none,false,"e.g., 55296",,
12+
11,input,southernmost_latitude,Southernmost Latitude,Degrees north (-90 to 90).,none,false,"e.g., -89.5",,
13+
12,input,westernmost_longitude,Westernmost Longitude,Degrees east (0 to <360).,none,false,"e.g., 0.5",,
14+
13,dropdown,truncation_method,Truncation Method,Spectral only.,truncation_method,false,,list_with_na,0
15+
14,input,truncation_number,Truncation Number,Spectral only.,none,false,"e.g., 127",,
16+
15,markdown,subgrid_header,,"## Horizontal Subgrid",none,false,,,
17+
16,multi-select,cell_variable_type,Variable Types,Variables at this subgrid.,cell_variable_type,true,,list,
18+
17,markdown,generated_header,,"## Auto-Generated\n\nCreates:\n- g### (grid_cells)\n- s### (subgrid → g###)\n\nDescriptions generated from inputs.",none,false,,,
19+
18,markdown,metadata_header,,"## Metadata",none,false,,,
20+
19,dropdown,issue_kind,Issue Kind,New or modify.,issue_kind,true,,list_with_na,0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Grid Cell and Subgrid Registration",
3+
"description": "Register horizontal grid cells and subgrid together",
4+
"title": "[EMD] Grid Cell and Subgrid:",
5+
"labels": ["emd-submission", "grid", "Review"],
6+
"issue_category": "grid_cell_and_subgrid",
7+
"dropdown_title": "Completion Guidance",
8+
"field_guidance": {
9+
"grid_type": "How cells are distributed over the region. Most common: regular-latitude-longitude, reduced-gaussian, tripolar, cubed-sphere.",
10+
"cell_variable_type": "Types of variables at this subgrid location. mass: thermodynamic quantities, x-velocity/y-velocity: velocity components, velocity: full vector for unstructured grids."
11+
}
12+
}
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Grid Cell and Subgrid Template Data
2+
# Loads CVs from CMIP-LD to avoid hardcoding
3+
4+
import cmipld
5+
from cmipld.utils.ldparse import name_multikey_extract
6+
7+
# Data for this template - loaded from CVs
8+
DATA = {
9+
# Grid types from CV
10+
'grid_type': name_multikey_extract(
11+
cmipld.get('constants:grid_type/graph.jsonld', depth=0),
12+
['id', 'validation_key'], 'validation_key'
13+
),
14+
15+
# Grid mapping from CV
16+
'grid_mapping': name_multikey_extract(
17+
cmipld.get('constants:grid_mapping/graph.jsonld', depth=0),
18+
['id', 'validation_key'], 'validation_key'
19+
),
20+
21+
# Region from CV
22+
'region': name_multikey_extract(
23+
cmipld.get('constants:region/graph.jsonld', depth=0),
24+
['id', 'validation_key'], 'validation_key'
25+
),
26+
27+
# Temporal refinement from CV
28+
'temporal_refinement': name_multikey_extract(
29+
cmipld.get('constants:temporal_refinement/graph.jsonld', depth=0),
30+
['id', 'validation_key'], 'validation_key'
31+
),
32+
33+
# Units from CV
34+
'units': name_multikey_extract(
35+
cmipld.get('constants:units/graph.jsonld', depth=0),
36+
['id', 'validation_key'], 'validation_key'
37+
),
38+
39+
# Truncation method from CV
40+
'truncation_method': name_multikey_extract(
41+
cmipld.get('constants:truncation_method/graph.jsonld', depth=0),
42+
['id', 'validation_key'], 'validation_key'
43+
),
44+
45+
# Cell variable types from CV
46+
'cell_variable_type': name_multikey_extract(
47+
cmipld.get('constants:cell_variable_type/graph.jsonld', depth=0),
48+
['id', 'validation_key'], 'validation_key'
49+
),
50+
51+
# Issue metadata
52+
'issue_kind': ['New', 'Modify']
53+
}
54+
55+
56+
def generate_grid_cell_and_subgrid(issue_data):
57+
"""
58+
Generate horizontal_grid_cells and horizontal_subgrid from issue data.
59+
60+
Auto-generates:
61+
- Grid cells description from properties
62+
- Subgrid description from variable types
63+
- IDs (g###, s###)
64+
- Cross-reference link
65+
66+
Returns:
67+
dict: {
68+
'grid_cells_id': 'g100',
69+
'subgrid_id': 's100',
70+
'entities': {
71+
'horizontal_grid_cells': {...},
72+
'horizontal_subgrid': {...}
73+
}
74+
}
75+
"""
76+
# Get next available IDs
77+
grid_cells_id = get_next_id('horizontal_grid_cells') # e.g., g100
78+
subgrid_id = get_next_id('horizontal_subgrid') # e.g., s100
79+
80+
# Auto-generate grid_cells description
81+
grid_cells_desc = generate_grid_cells_description(issue_data)
82+
# Example: "Global regular-latitude-longitude grid with 1.25° x 0.9° resolution and 55296 cells."
83+
84+
# Auto-generate subgrid description
85+
subgrid_desc = generate_subgrid_description(issue_data)
86+
# Example: "Mass variables on a regular latitude-longitude grid."
87+
88+
# Create grid_cells entity
89+
grid_cells = {
90+
'validation_key': grid_cells_id,
91+
'ui_label': '',
92+
'description': grid_cells_desc,
93+
'grid_type': issue_data['grid_type'],
94+
'grid_mapping': issue_data['grid_mapping'],
95+
'region': issue_data['region'],
96+
'temporal_refinement': issue_data['temporal_refinement'],
97+
'@context': '_context',
98+
'@type': ['emd', 'wcrp:horizontal_grid_cells', 'esgvoc:HorizontalGridCells'],
99+
'@id': grid_cells_id
100+
}
101+
102+
# Add optional fields if provided
103+
if issue_data.get('x_resolution'):
104+
grid_cells['x_resolution'] = float(issue_data['x_resolution'])
105+
if issue_data.get('y_resolution'):
106+
grid_cells['y_resolution'] = float(issue_data['y_resolution'])
107+
if issue_data.get('units'):
108+
grid_cells['units'] = issue_data['units']
109+
if issue_data.get('n_cells'):
110+
grid_cells['n_cells'] = int(issue_data['n_cells'])
111+
if issue_data.get('southernmost_latitude'):
112+
grid_cells['southernmost_latitude'] = float(issue_data['southernmost_latitude'])
113+
if issue_data.get('westernmost_longitude'):
114+
grid_cells['westernmost_longitude'] = float(issue_data['westernmost_longitude'])
115+
if issue_data.get('truncation_method'):
116+
grid_cells['truncation_method'] = issue_data['truncation_method']
117+
if issue_data.get('truncation_number'):
118+
grid_cells['truncation_number'] = int(issue_data['truncation_number'])
119+
120+
# Create subgrid entity (auto-linked)
121+
subgrid = {
122+
'validation_key': subgrid_id,
123+
'ui_label': '',
124+
'description': subgrid_desc,
125+
'cell_variable_type': issue_data['cell_variable_type'],
126+
'horizontal_grid_cells': grid_cells_id, # Auto-link
127+
'@context': '_context',
128+
'@type': ['emd', 'wcrp:horizontal_subgrid', 'esgvoc:HorizontalSubgrid'],
129+
'@id': subgrid_id
130+
}
131+
132+
return {
133+
'grid_cells_id': grid_cells_id,
134+
'subgrid_id': subgrid_id,
135+
'entities': {
136+
'horizontal_grid_cells': grid_cells,
137+
'horizontal_subgrid': subgrid
138+
}
139+
}
140+
141+
142+
def generate_grid_cells_description(data):
143+
"""Generate description for grid_cells from properties."""
144+
parts = []
145+
146+
# Region
147+
if data.get('region'):
148+
if 'global' in data['region']:
149+
parts.append('Global')
150+
else:
151+
parts.append(' '.join(data['region']))
152+
153+
# Grid type
154+
parts.append(data.get('grid_type', '').replace('-', ' '))
155+
parts.append('grid')
156+
157+
# Resolution
158+
if data.get('x_resolution') and data.get('y_resolution'):
159+
parts.append(f"with {data['x_resolution']}° x {data['y_resolution']}° resolution")
160+
161+
# Cell count
162+
if data.get('n_cells'):
163+
parts.append(f"and {data['n_cells']} cells")
164+
165+
return ' '.join(parts) + '.'
166+
167+
168+
def generate_subgrid_description(data):
169+
"""Generate description for subgrid from variable types."""
170+
var_types = data.get('cell_variable_type', [])
171+
grid_type = data.get('grid_type', '').replace('-', ' ')
172+
173+
# Format variable types
174+
if len(var_types) == 1:
175+
var_str = var_types[0].replace('_', ' ').replace('-', ' ').capitalize()
176+
else:
177+
var_str = ' and '.join(v.replace('_', ' ') for v in var_types).capitalize()
178+
179+
return f"{var_str} variables on a {grid_type} grid."

.github/GEN_ISSUE_TEMPLATE/grid_cells_and_subgrid.csv

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)