Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boomstick()
- path = '/path/to/data/'
- f = path+'DR_ABI-L2-CMIPC-M3C01_G16_s20152322000151_e20152322002542_c20152322002596.nc'
- cmi = loadGrid(filename=f, field='CMI')
- dqf = loadGrid(filename=f, field='DQF')
- l = activeDisplay().createLayer('Color-Shaded Plan View', cmi)
- # Test global file attributes
- globalAttrs = cmi['globalAttributes']
- print('Global Attribute "scene_id": {}'.format(globalAttrs['scene_id']))
- print('Global Attribute "platform_id": {}'.format(globalAttrs['platform_ID']))
- print('Global Attribute "timeline_id": {}'.format(globalAttrs['timeline_id']))
- # Test attributes associated with the variable we loaded
- varAttrs = cmi['variableAttributes']
- print('String variable attribute "resolution": {}'.format(varAttrs['resolution']))
- assert type(varAttrs['resolution']) is unicode
- print('Numeric variable attribute "sensor_band_bit_depth": {}'.format(
- varAttrs['sensor_band_bit_depth']))
- assert type(varAttrs['sensor_band_bit_depth']) is int
- varAttrs = dqf['variableAttributes']
- print('Array variable attribute "flag_values": {}'.format(
- varAttrs['flag_values']))
- assert type(varAttrs['flag_values']) is list
- assert type(varAttrs['flag_values'][0]) is int
- # Test single-valued variables, aka "metadata variables"
- # Note: We have nested dicts within nested dicts here!
- metadataVars = cmi['metadataVariables']
- print('Value of t variable: {}'.format(metadataVars['t']['value']))
- print('t variable also has attributes! long_name: {}'.format(
- metadataVars['t']['attributes']['long_name']))
- # Test metadata still accessible post-formula through "getMetadataMap"
- result = sub(cmi, cmi)
- print('Global Attribute "scene_id" post-formula: {}'.format(
- result.getMetadataMap().get('globalAttributes')['scene_id']))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement