Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. boomstick()
  2.  
  3. path = '/path/to/data/'
  4. f = path+'DR_ABI-L2-CMIPC-M3C01_G16_s20152322000151_e20152322002542_c20152322002596.nc'
  5.  
  6. cmi = loadGrid(filename=f, field='CMI')
  7. dqf = loadGrid(filename=f, field='DQF')
  8.  
  9. l = activeDisplay().createLayer('Color-Shaded Plan View', cmi)
  10.  
  11. # Test global file attributes
  12. globalAttrs = cmi['globalAttributes']
  13.  
  14. print('Global Attribute "scene_id": {}'.format(globalAttrs['scene_id']))
  15. print('Global Attribute "platform_id": {}'.format(globalAttrs['platform_ID']))
  16. print('Global Attribute "timeline_id": {}'.format(globalAttrs['timeline_id']))
  17.  
  18. # Test attributes associated with the variable we loaded
  19. varAttrs = cmi['variableAttributes']
  20.  
  21. print('String variable attribute "resolution": {}'.format(varAttrs['resolution']))
  22. assert type(varAttrs['resolution']) is unicode
  23.  
  24. print('Numeric variable attribute "sensor_band_bit_depth": {}'.format(
  25. varAttrs['sensor_band_bit_depth']))
  26. assert type(varAttrs['sensor_band_bit_depth']) is int
  27.  
  28. varAttrs = dqf['variableAttributes']
  29. print('Array variable attribute "flag_values": {}'.format(
  30. varAttrs['flag_values']))
  31. assert type(varAttrs['flag_values']) is list
  32. assert type(varAttrs['flag_values'][0]) is int
  33.  
  34. # Test single-valued variables, aka "metadata variables"
  35. # Note: We have nested dicts within nested dicts here!
  36. metadataVars = cmi['metadataVariables']
  37. print('Value of t variable: {}'.format(metadataVars['t']['value']))
  38. print('t variable also has attributes! long_name: {}'.format(
  39. metadataVars['t']['attributes']['long_name']))
  40.  
  41. # Test metadata still accessible post-formula through "getMetadataMap"
  42. result = sub(cmi, cmi)
  43. print('Global Attribute "scene_id" post-formula: {}'.format(
  44. result.getMetadataMap().get('globalAttributes')['scene_id']))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement