-
Notifications
You must be signed in to change notification settings - Fork 0
/
netcdf_exploration.py
42 lines (40 loc) · 2.15 KB
/
netcdf_exploration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def overview(current_ncfile):
for group_count, group_name in enumerate(current_ncfile.groups):
group = current_ncfile.groups[group_name]
print(f"TopGroup Nr. {group_count + 1}: {group_name}")
print("---------------------------------------------------------")
for group_name in current_ncfile.groups:
group = current_ncfile.groups[group_name]
print(f"TopGroup: {group_name}")
for variable_group in group.variables:
group_variable = group.variables[variable_group]
print(f" Groupvariable: {variable_group}")
for subgroup_name in group.groups:
subgroup = group.groups[subgroup_name]
print(f" Subgroup: {subgroup_name}")
for variable_name in subgroup.variables:
variable = subgroup.variables[variable_name]
print(f" SubGroupVariable: {variable_name}")
print("---------------------------------------------------------")
def topgroup_variables(current_ncfile, topgroup_name):
for variable_name in current_ncfile.groups[topgroup_name].variables:
variable = current_ncfile.groups[topgroup_name].variables[variable_name]
print(f"Variable Name: {variable_name}")
print(f"Variable Attributes:")
print(f" Units: {variable.units}")
print(f" Long Name: {variable.long_name}")
print(f" Shape: {variable.shape}")
print("---------------------------------------------------------")
def sub_groups(current_ncfile, top_group_name):
top_group_name = current_ncfile.groups[top_group_name]
for subgroup_name in top_group_name.groups:
subgroup = top_group_name.groups[subgroup_name]
print(f"SUBGROUP: {subgroup_name}")
for variable_name in subgroup.variables:
variable = subgroup.variables[variable_name]
print(f"Variable Name: {variable_name}")
print(f"Variable Attributes:")
print(f" Units: {variable.units}")
print(f" Long Name: {variable.long_name}")
print(f" Shape: {variable.shape}")
print("---------------------------------------------------------")