#############################################################################_80
#_NAME: 	libmeta.py						       #
#_PURPOSE:	Single file to store model and other metadata tables	       #
#_USAGE:	Library only, does nothing when run from shell		       #
#_AUTHOR:	Walter R. Sessions, September 2011			       #
#									       #
#############################################################################_80
#_DICTIONARIES AND LOOKUP TABLES_###############################################
#################################################################################_Some of the dictionaries below could be global variables, but some can't
# be. For stylistic consistency, they are left as modules.

#_If a central variable is desired to increase or decrease
# debug messages, set all library debug values to 'lm.debug'
#_Higher values result in noisier logs.  
#_The libraries each have their own copy of dbg() which checks
# against the local value of debug and will print messages kwarg'd
# with a value less then debug.
debug = 1

#_Set globally used directories
import os
dir_prod 	= os.environ['PRODUCTS']	#_Location for model outputs
dir_ops		= '.'#os.environ['OPS']		#_Location of pseudo-ops runs 
dir_fcst 	= '.'#os.environ['METMOD_FCST']	#_Location of Met Forecast
dir_anal 	= '.'#os.environ['METMOD_ANAL']	#_Location of Met Analysese 
dir_ensfcst 	= '.'#os.environ['ENS_FCST']	#_Location of Ensemble Forecast
dir_web		= '.'#os.environ['WEB'] + '/globaer'#_Path to web output

#_default naaps namelist options
def namelist():
	pass

#_List of current icap models
def current_icap(): return ['MACC','GEOS5','NAAPS','MASINGAR','NGAC','NMMB'][:]

def models():
	'''returns dictionary of expected metadata for all models'''
	f = {}
	[ f.update( { k : v } ) for k,v in ensemble_models().iteritems() ]
	[ f.update( { k : v } ) for k,v in deterministic_models().iteritems() ]
	return f

def ensemble_models():
	''' 
	returns dictionary of expected metadata for ensembles
	TODO: 	Consolidate dict.keys(), name, and dir.  Get rid of all the
		model()[name]['dir'] instances 

	'''
        models  = {     'ENAAPS-NAV': {	'label'  :'ENAAPS-NAV',
                                        'legend':'NAAPS Ens $\mu$',
                                        'prefix':'Meteorological Ensemble ',
                                        'specs' :['Sulfate_AOD','Dust_AOD',
                                                'Smoke_AOD','SeaSalt_AOD',
                                                'Total_AOD'],
                                        'color' : 'red',
                                        'foot'  :'NOT OFFICIAL FNMOC NAAPS RUN',
                                        'web'   :'ens_01',
                                        'dir'   :'ENAAPS-NAV',
				    'fcst_finc' : 12,
					'fhr'	: 120,
					'finc'	: 6,
                                        'nens'  : 20	},
			'ENAAPS-DART': {'label'  :'ENAAPS-DART',
                                        'legend':'NAAPS Ens $\mu$',
                                        'prefix':'DART Ensemble ',
                                        'specs' :['Sulfate_AOD','Dust_AOD',
                                                'Smoke_AOD','SeaSalt_AOD',
                                                'Total_AOD'],
                                        'color' : 'red',
                                        'foot'  :'NOT OFFICIAL FNMOC NAAPS RUN',
                                        'web'   :'dart_01',
                                        'dir'   : 'ENAAPS-DART',
				    'fcst_finc' : 12,
					'fhr'	: 120,
					'finc'	: 6,
                                        'nens'  : 20	},
			'ICAP' : {      'label'  :'ICAP',
                                        'prefix':'',
                                        'specs' :['Sulfate_AOD','Dust_AOD',
                                                'Smoke_AOD','Seasalt_AOD',
                                                'Total_AOD'],
                                        'foot'  :'',
                                        'color' : 'red',
                                        'web'   :'icap_01',
                                        'dir'   : 'ICAP',
				    'fcst_finc' : 24,
					'fhr'	: 120,
					'finc'	: 6,
                                        'nx'    : 360,
                                        'ny'    : 180	}       }
        return models

def deterministic_models():
        '''
	Returns expected metadata for deterministic models
        Specs listed here are what is PLOTTED, not what's AVAILABLE

	npp_# runs are Ed Hyer's

	specn are species native from download

	fhr in this context is the forecast length

	TODO: 	Consolidate dict.keys(), name, and dir.  Get rid of all the
		model()[name]['dir'] instances 
        '''
        models  = {     'NAAPS'   : {   'label'  : 'NAAPS',
                                        'prefix': '',
                                        'specs' : ['Sulfate_AOD','Dust_AOD',
                                                  'Smoke_AOD','Seasalt_AOD',
                                                  'Total_AOD'],
                                        'sexpt' : ['Sulfate_AOD','Dust_AOD',
                                                  'Smoke_AOD','Seasalt_AOD',
                                                  'Total_AOD'],
                                        'color' : 'black',
                                        'foot'  : 'NOT OFFICIAL FNMOC RUN',
                                        'web'   : 'nva_02',
                                        'dir'   : 'NVA',
                                        'nx'    : 360,
                                        'ny'    : 180,
				 	'fhr'	: 120,
				   'fcst_finc'	: 12,
                                        'finc'  : 6     },
                        'NPP_OCEAN': {  'label'  : 'NAAPS_NPP-Ocean',
                                        'prefix': '',
                                        'specs' : ['Sulfate_AOD','Dust_AOD',
                                                  'Smoke_AOD','Seasalt_AOD',
                                                  'Total_AOD'],
                                        'color' : 'black',
                                        'foot'  : 'NOT OFFICIAL FNMOC RUN',
                                        'web'   : 'npp_01',
                                        'dir'   : 'NPP_ocean',
                                        'nx'    : 360,
                                        'ny'    : 180,
				 	'fhr'	: 72,
				   'fcst_finc'	: 12,
                                        'finc'  : 6     },
                        'NPP_LAND' : {  'label'  : 'NAAPS_NPP-Land',
                                        'prefix': '',
                                        'specs' : ['Sulfate_AOD','Dust_AOD',
                                                  'Smoke_AOD','Seasalt_AOD',
                                                  'Total_AOD'],
                                        'color' : 'black',
                                        'foot'  : 'NOT OFFICIAL FNMOC RUN',
                                        'web'   : 'npp_02',
                                        'dir'   : 'NPP_land',
                                        'nx'    : 360,
                                        'ny'    : 180,
				 	'fhr'	: 72,
				   'fcst_finc'	: 12,
                                        'finc'  : 6     },
                        'NPP_TEXTURAL' : {  'label'  : 'NAAPS_NPP-textural',
                                        'prefix': '',
                                        'specs' : ['Sulfate_AOD','Dust_AOD',
                                                  'Smoke_AOD','Seasalt_AOD',
                                                  'Total_AOD'],
                                        'color' : 'black',
                                        'foot'  : 'NOT OFFICIAL FNMOC RUN',
                                        'web'   : 'npp_03',
                                        'dir'   : 'NPP_textural',
                                        'nx'    : 360,
                                        'ny'    : 180,
				 	'fhr'	: 72,
				   'fcst_finc'	: 12,
                                        'finc'  : 6     },
                        'NODA'   : {    'label'  : 'NAAPS_NODA',
                                        'prefix': '',
                                        'specs' : ['Sulfate_AOD','Dust_AOD',
                                                  'Smoke_AOD','Seasalt_AOD',
                                                  'Total_AOD'],
                                        'color' : 'black',
                                        'foot'  : 'NOT OFFICIAL FNMOC RUN',
                                        'web'   : 'npp_03',
                                        'dir'   : 'NODA',
                                        'nx'    : 360,
                                        'ny'    : 180,
				 	'fhr'	: 78,
				   'fcst_finc'	: 12,
                                        'finc'  : 6     },
                        'NVA_04'   : {  'label'  : 'NAAPS_ICAP',
                                        'prefix': '',
                                        'specs' : ['Sulfate_AOD','Dust_AOD',
                                                  'Smoke_AOD','Seasalt_AOD',
                                                  'Total_AOD'],
                                        'color' : 'black',
                                        'foot'  : 'NOT OFFICIAL FNMOC RUN',
                                        'web'   : 'npp_04',
                                        'dir'   : 'NVA_04',
                                        'nx'    : 360,
                                        'ny'    : 180,
				 	'fhr'	: 72,
				   'fcst_finc'	: 12,
                                        'finc'  : 6     },
                        'GEOS5' : {     'label'  : 'GEOS-5',
                                        'prefix': '',
                                        'specs' : ['Dust_AOD','Seasalt_AOD',
                                                  'BlackCarbon_AOD',
                                                  'Sulfate_AOD',
                                                  'OrganicCarbon_AOD',
                                                  'Smoke_AOD','Total_AOD'],
                                        'specn' : ['Dust_AOD','Seasalt_AOD',
                                                  'BlackCarbon_AOD',
                                                  'Sulfate_AOD',
                                                  'OrganicCarbon_AOD' ],
                                        'color' : 'magenta',
                                        'foot'  : 'GEOS-5 model output produced'
                                                  +' by NASA Global Modeling'
                                                  +' and Assimilation Office',
                                        'web'   : 'geos5_01',
                                        'dir'   : 'GEOS5',
				 	'fhr'	: 120,
				   'fcst_finc'	: 24,
                                        'finc'  : 1     },
                        'MACC' : {      'label'  : 'MACC',
                                        'prefix': '',
                                        'specs' : ['BiomassBurning_AOD',
						  'BlackCarbon_AOD',
                                                  'OrganicMatter_AOD',
                                                  'Seasalt_AOD',
                                                  'Sulfate_AOD','Dust_AOD',
                                                  'Total_AOD','Smoke_AOD'],
                                        'specn' : ['BiomassBurning_AOD',
						  'BlackCarbon_AOD',
                                                  'OrganicMatter_AOD',
                                                  'Seasalt_AOD',
                                                  'Sulphate_AOD','Dust_AOD',
                                                  'Total_AOD'],
                                        'color' : 'orange',
                                        'foot'  : '',
                                        'web'   : 'macc_01',
                                        'dir'   : 'MACC',
				 	'fhr'	: 120,
				   'fcst_finc'	: 24,
                                        'finc'  : 3     },
                        'MASINGAR' : {  'label'  : 'MASINGAR',
                                        'prefix': '',
                                        'specs' : ['Sulfate_AOD','Dust_AOD',
                                                  'Smoke_AOD','Seasalt_AOD',
                                                  'Total_AOD'],
                                        'color' : 'green',
                                        'foot'  : '',
                                        'web'   : 'masingar_01',
                                        'dir'   : 'MASINGAR',
                                        'finc'  : 6     },
                        'NGAC' : {      'label'  : 'NGAC',
                                        'prefix': '',
                                        'specs' : ['Dust_AOD'],
                                        'color' : 'blue',
                                        'foot'  : '',
                                        'web'   : 'ngac_01',
                                        'dir'   : 'NGAC',
					 'fhr'	: 120,
				   'fcst_finc'	: 24,
                                        'finc'  : 6     },
                        'NMMB' : {      'label'  : 'NMMB/BSC-CTM',
                                        'prefix': '',
                                        'specs' : ['Dust_AOD', 'Seasalt_AOD'],
                                        'color' : 'brown',
                                        'foot'  : '',
                                        'web'   : 'nmmb_01',
                                        'dir'   : 'NMMB',
				 	'fhr'	: 120,
				   'fcst_finc'	: 24,
                                        'finc'  : 6     },      }
        return models

def fields():
	f = {}
	[ f.update( { k : v } ) for k,v in fields_det().iteritems() ]
	[ f.update( { k : v } ) for k,v in fields_ens().iteritems() ]
	return f

def fields_det():
	"""
	Dictionary describing deterministic model fields
	"""
	import libtools as lt
	fields	= {	'aod' : {	'levs'	: [.1,.2,.4,.8,1.2,2.5,5.,9.],
					'colors': lt.rgbgen('aod'),
					'level'	: '550',
				'title'	:'Aerosol Optical Depth at 550nm' } }	
	return fields

def fields_ens():
	import libtools as lt
        fields  = {     'warn': {       'levs'  : [.8,100.],
                                        'colors': lt.rgbgen('warn'),
                                        'level' : '550',
        'title' : 'AOD Warning Area (>50% members above 0.8)' },
                        'musig': {      'levs'  : [.1,.4,1.2,5.,9.],
                                        'colors': lt.rgbgen('musig'),
                                        'level' : '550',
        'title' : 'Mean AOD at 550nm (white) with Nrml Spread (fill)' },
                        'spag': {       'levs'  : [0.8],
                                        'colors': [],
                                        'level' : '550',
        'title' : '0.8 Aerosol Optical Depth at 550nm ($\mu$ in red)' }, }
        return fields

def sensors():
	pre = '/shared/aerosol_dev2/testing/flambe2/archive_processed/'
	post = '/hourly/v12'
	sats = {     	'modis'   : {	'name'  : 'MODIS_L3',
                      			'prefix': '',
                                        'foot'  : '',
					'dir' 	: pre + 'modis' + post,
					'sats'	: ('aqua','terra'),
                                        'web'   : 'sat_01' }, 
			'goes'   : {	'name'  : 'GOES',
                      			'prefix': '',
                                        'foot'  : '',
					'sats'	: ('g8','g10','g11','g12',
							'g13', 'g14', 'g15'),
					'dir' 	: pre + 'goes' + post,
                                        'web'   : 'goes_01' }, 
			'avhrr'   : {	'name'  : 'AVHRR_L3',
                      			'prefix': '',
                                        'foot'  : '',
                                        'web'   : 'sat_01' },	
			'viirs'   : {	'name'  : 'VIIRS_L3',
                      			'prefix': '',
                                        'foot'  : '',
                                        'web'   : 'sat_01' } 	}
	return sats

def ieee_vars( nz, ny, nx ):
	vars	= {	'so2'	: {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz,ny,nx),
				'units'		: 'ugS m-3',
				'_FillValue'	: '-999',
				'long_name' 	: 'sulfur dioxide mass ' + \
						  'concentration' },
			'sulfate': {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz,ny,nx),
				'units'		: 'ugS m-3',
				'_FillValue'	: '-999',
				'long_name' 	: 'sulfate mass concentration'},
			'dust': {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz,ny,nx),
				'units'		: 'ug m-3',
				'_FillValue'	: '-999',
				'long_name' 	: 'dust mass concentration'},
			'smoke': {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz,ny,nx),
				'units'		: 'ug m-3',
				'_FillValue'	: '-999',
				'long_name' 	: 'smoke mass concentration'},
			'sea_salt': {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz,ny,nx),
				'units'		: 'ug m-3',
				'_FillValue'	: '-999',
				'long_name' 	: 'seasalt mass concentration'},
			'so2_source': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'so2 emit, since start of ' +\
						  'month'},
			'sulfate_source': {
				'dims'		: ('lat','lon'),
				'_FillValue'	: '-999',
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'long_name' 	: 'sulfate emit, since start '+\
						  'of month'},
			'dust_source': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'_FillValue'	: '-999',
				'units'		: 'kg m-2',
				'long_name' 	: 'dust emit, since start of '+\
						  'month'},
			'smoke_source': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'smoke emit, since start of'+\
						  ' month'},
			'seasalt_source': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'seasalt emit, since start '+\
						  'of month'},
			'so2_dep': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'so2 depo, since start of '+\
						  'month'},
			'sulfate_dep': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'sulfate depo, since start '+\
						  'of month'},
			'dust_dep': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'dust depo, since start of '+\
						  'month'},
			'smoke_dep': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'smoke depo, since start of'+\
						  ' month'},
			'seasalt_dep': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'seasalt depo, since start '+\
						  'of month'},
			'so2_scav': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'so2 scav, since start of '+\
						  'month'},
			'sulfate_scav': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'sulfate scav, since start '+\
						  'of month'},
			'dust_scav': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'dust scav, since start of '+\
						  'month'},
			'smoke_scav': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'smoke scav, since start of'+\
						  ' month'},
			'seasalt_scav': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'kg m-2',
				'_FillValue'	: '-999',
				'long_name' 	: 'seasalt scav, since start '+\
						  'of month'},
			'so2_aod': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: ' ',
				'_FillValue'	: '-999',
				'long_name' 	: 'so2 aerosol optical depth'},
			'sulfate_aod': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: ' ',
				'_FillValue'	: '-999',
				'long_name' 	: 'sulfate aerosol optical '+\
						  'depth'},
			'dust_aod': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: ' ',
				'_FillValue'	: '-999',
				'long_name' 	: 'dust aerosol optical depth'},
			'smoke_aod': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: ' ',
				'_FillValue'	: '-999',
				'long_name' 	: 'smoke aerosol optical depth'},
			'seasalt_aod': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: ' ',
				'_FillValue'	: '-999',
				'long_name' 	: 'seasalt aerosol optical '+\
						  'depth'},
			'mix': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'meters',
				'_FillValue'	: '-999',
				'long_name'	: 'mixing length' },	
			'height': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'meters',
				'_FillValue'	: '-999',
				'long_name'	: 'terrain height' },
			'ocean': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'fraction',
				'_FillValue'	: '-999',
				'long_name'	: 'ocean fractional coverage' },
			'land': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'fraction',
				'_FillValue'	: '-999',
				'long_name'	: 'land fractional coverage' },
			'seaice': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'fraction',
				'_FillValue'	: '-999',
				'long_name'	: 'seaice fractional coverage'},
			'glacier': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'fraction',
				'_FillValue'	: '-999',
				'long_name'	: 'glacier fractional coverage'},
			'drag': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'kgm-1s-1',
				'_FillValue'	: '-999',
				'long_name'	: 'surface stress'},
			'u*': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'ms-1',
				'_FillValue'	: '-999',
				'long_name'	: 'friction velocity'},
			'sfc_temp': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'K',
				'_FillValue'	: '-999',
				'long_name'	: 'surface/ocean temperature'},
			'precip_cum': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'cm/6_hr',
				'_FillValue'	: '-999',
				'long_name'	: 'cumulus precipitation'},
			'precip_strat': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'cm/6_hr',
				'_FillValue'	: '-999',
				'long_name'	: 'stratiform precipitation'},
			'top_cum': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'hPa',
				'_FillValue'	: '-999',
				'long_name'	: 'pressure at top of cum '+\
						  'precip'},
			'sfc_pres': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'hPa',
				'_FillValue'	: '-999',
				'long_name'	: 'surface pressure'},
			'sfc_fluxL': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'Wm-2',
				'_FillValue'	: '-999',
				'long_name'	: 'surface heat flux, latent'},
			'sfc_fluxS': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'_FillValue'	: '-999',
				'units'		: 'Wm-2',
				'long_name'	: 'surface heat flux, sensible'},
			'sfc_soilwet': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'fraction',
				'_FillValue'	: '-999',
				'long_name'	: 'surface soil wetness'},
			'snow_depth': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'cm',
				'_FillValue'	: '-999',
				'long_name'	: 'snow depth'},
			'lcl_press': {
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'hPa',
				'_FillValue'	: '-999',
				'long_name'	: 'pressure at lcl'},
			'cum_coverage' :{
				'dims'		: ('lat','lon'),
				'shape'		: (ny, nx),
				'units'		: 'fraction',
				'_FillValue'	: '-999',
				'long_name'	:'cumulus convection coverage'},
			'U' :{
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'ms-1',
				'_FillValue'	: '-999',
				'long_name'	: 'zonal wind component'},
			'V' :{
				'_FillValue'	: '-999',
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'ms-1',
				'long_name'	: 'meridional wind component'},
			'T' :{
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'K',
				'_FillValue'	: '-999',
				'long_name'	: 'temperature'},
			'W' :{
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'psc/s',
				'_FillValue'	: '-999',
				'long_name'	: 'omega vertical vel at layer'
						  +' centers'},
			'geopotential_hgt' :{
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'm',
				'_FillValue'	: '-999',
				'long_name'	: 'geopotential height'},
			'spec_hum' :{
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'gg-1',
				'_FillValue'	: '-999',
				'long_name'	: 'specific humidity'},
			'rel_hum' :{
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'percent',
				'_FillValue'	: '-999',
				'long_name'	: 'relative humidity'},
			'Td'	: {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'C',
				'_FillValue'	: '-999',
				'long_name'	: 'dew point temperature'},
			'vapor_mixing'	: {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'kgkg-1',
				'_FillValue'	: '-999',
				'long_name'	: 'water vapor mixing ratio'},
			'potential_temp'	: {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'K',
				'_FillValue'	: '-999',
				'long_name'	: 'potential temperature'},
			'wind_dir'	: {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'deg (azimuthal)',
				'_FillValue'	: '-999',
				'long_name'	: 'wind direction'},
			'wind_speed'	: {
				'dims'		: ('press','lat','lon'),
				'shape'		: (nz, ny, nx),
				'units'		: 'ms-1',
				'_FillValue'	: '-999',
				'long_name'	: 'wind speed'},
		}
	order = [	'so2', 'sulfate','dust','smoke','sea_salt',
			'so2_source','sulfate_source','dust_source',
			'smoke_source','seasalt_source','so2_dep','sulfate_dep',
			'dust_dep','smoke_dep','seasalt_dep','so2_scav',
			'sulfate_scav','dust_scav','smoke_scav','seasalt_scav',
			'so2_aod','sulfate_aod','dust_aod','smoke_aod',
			'seasalt_aod','mix','height','ocean','land','seaice',
			'glacier','drag','u*','sfc_temp','precip_cum',
			'precip_strat','top_cum','sfc_pres','sfc_fluxL',
			'sfc_fluxS','sfc_soilwet','snow_depth','lcl_press',
			'cum_coverage','U','V','T','W','geopotential_hgt',
			'spec_hum','rel_hum','Td','vapor_mixing',
			'potential_temp','wind_dir','wind_speed']
	return 		vars, order

def nog_vars ( nz, ny, nx ):
	d2 = str( ny * nx )
	d3 = str( ny * nx * nz )
	vars = {	'height' 	: 	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'm',
				'dtype'		: [('height', d2+'i2')],
				'long_name'	: 'terrain height'	},
			'sigma'	: 	{
				'dims'		: ('sigma',),
				'shape'		: (2*(nz+1),),
				'units'		: '',
				'dtype'		: [('sig_a', str(nz+1)+'f4'),\
						('sig_b', str(nz+1)+'f4')],
				'long_name'	: 'hybrid sigma levels'	},
			'sig_a'	: 	{
				'dims'		: ('sigma_staggered',),
				'shape'		: (nz+1,),
				'units'		: '',
				'long_name'	: 'hybrid sigma levels'	},
			'sig_b'	: 	{
				'dims'		: ('sigma_staggered',),
				'shape'		: (nz+1,),
				'units'		: '',
				'long_name'	: 'hybrid sigma levels'	},
			'lat'	: 	{
				'dims'		: ('lat',),
				'shape'		: (ny,),
				'units'		: 'degrees_north',
				'dtype'		: [('lat', str(ny)+'f4')],
				'long_name'	: 'latitudes'	},
			'lon'	: 	{
				'dims'		: ('lon',),
				'shape'		: (nx,),
				'units'		: 'degrees_east',
				'dtype'		: [('lon', str(nx,)+'f4')],
				'long_name'	: 'longitudes'	},
			'p_top'	: 	{
				'dims'		: ('none',),
				'shape'		: (1,),
				'units'		: 'hPa',
				'long_name'	: 'pressure at top of atmos'},
			'flag_ocean'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'unitless',
				'dtype'		: [('flag_ocean', d2+'i2')],
				'long_name'	: 'ocean flag'		},
			'flag_land'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'unitless',
				'dtype'		: [('flag_land', d2+'i2')],
				'long_name'	: 'land flag'		},
			'flag_seaice'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'unitless',
				'dtype'		: [('flag_seaice', d2+'i2')],
				'long_name'	: 'SeaIce Flag'		},
			'flag_glacier'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'unitless',
				'dtype'		: [('flag_glacier', d2+'i2')],
				'long_name'	: 'Glacier Flag'	},
			'surface_drag'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('surface_drag', d2+'i2')],
				'long_name'	: 'Surface Drag Force'	},
			'latent_heat'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('latent_heat', d2+'i2')],
				'long_name'	: 'Latent Heat'		},
			'sensible_heat'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('sensible_heat', d2+'i2')],
				'long_name'	: 'sensible heat'	},
			'sfc_temp'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'K',
				'dtype'		: [('sfc_temp', d2+'i2')],
				'long_name'	: 'surface temperature'	},
			'sfc_wetness'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'fractional',
				'dtype'		: [('sfc_wetness', d2+'i2')],
				'long_name'	: 'surface wetness'	},
			'snow_depth'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'meters',
				'dtype'		: [('snow_depth', d2+'i2')],
				'long_name'	: 'snow depth'		},
			'precip_cumulus':	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('precip_cumulus', d2+'i2')],
				'long_name'	: 'cumulus precipitation'},
			'precip_stratus':	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('precip_stratus', d2+'i2')],
				'long_name'	: 'stratus precipitation'},
			'lcl'		:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'meters',
				'dtype'		: [('lcl', d2+'i2')],
				'long_name'	: 'lifting condensation level'},
			'top_of_cumulus':	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'meters',
				'dtype'		: [('top_of_cumulus', d2+'i2')],
				'long_name'	: 'top of cumulus'	},
			'fraction_cum'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'unitless',
				'dtype'		: [('fraction_cum', d2+'i2')],
				'long_name'	: 'cloud fraction, cumulus'},
			'sfc_pressure'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'hPa',
				'dtype'		: [('sfc_pressure', d2+'i2')],
				'long_name'	: 'surface pressure'	},
			'sfc_rh'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'per cent',
				'dtype'		: [('sfc_rh', d2+'i2')],
				'long_name'	: 'surface relative humidity' },
			'sfc_sh'	:	{
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: 'NOT SET',
				'dtype'		: [('sfc_sh', d2+'i2')],
				'long_name'	: 'surface specific humidity' },
			'u'		:	{
				'dims'		: ('sigma','lat','lon',),
				'shape'		: (nz,ny,nx,),
				'units'		: 'm s-1',
				'dtype'		: [('u', d2+'i2')],
				'long_name'	: 'zonal wind velocity'	},
			'v'		:	{
				'dims'		: ('sigma','lat','lon',),
				'shape'		: (nz,ny,nx,),
				'units'		: 'm s-1',
				'dtype'		: [('v', d2+'i2')],
				'long_name'	: 'meridional wind velocity'},
			'temperature'	:	{
				'dims'		: ('sigma','lat','lon',),
				'shape'		: (nz,ny,nx,),
				'units'		: 'K',
				'dtype'		: [('temperature', d2+'i2')],
				'long_name'	: 'temperature'		},
			'spec_humidity'	:	{
				'dims'		: ('sigma','lat','lon',),
				'shape'		: (nz,ny,nx,),
				'units'		: '',
				'dtype'		: [('spec_humidity', d2+'i2')],
				'long_name'	: 'specific humidity'	},
			'w'		:	{
				'dims'		: ('sigma','lat','lon',),
				'shape'		: (nz,ny,nx,),
				'units'		: 'm s-1',
				'dtype'		: [('w', d2+'i2')],
				'long_name'	: 'vertical wind velocity'},
			'pressure'	:	{
				'dims'		: ('sigma','lat','lon',),
				'shape'		: (nz,ny,nx,),
				'units'		: 'hPa',
				'dtype'		: [('pressure', d3+'i2')],
				'long_name'	: 'total atmospheric pressure'},
			'rho'		: {
				'dims'		: ('sigma','lat','lon',),
				'shape'		: (nz,ny,nx,),
				'units'		: 'kg m-3',
				'dtype'		: [('rho', d3+'f4')],
				'long_name'	: 'air density (particles)' },
			}

	order	= [	'sigma', 'lat', 'lon', 'height','flag_ocean',	\
			'flag_land','flag_seaice',	\
			'flag_glacier','surface_drag','latent_heat',	\
			'sensible_heat','sfc_temp','sfc_wetness',	\
			'snow_depth','precip_cumulus','precip_stratus',	\
			'lcl','top_of_cumulus','fraction_cum',		\
			'sfc_pressure','u','v',	'temperature',		\
			'spec_humidity','w']

	return vars, order

def aod_vars( ny=180, nx=360 ):
	d2 = str( ny * nx )
	vars	= {	'total_aod'		: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('total', d2+'f4')],
				'long_name'	: 'total aerosol optical '\
						  'depth'},
			'sulfate_aod'		: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('sulfate', d2+'f4')],
				'long_name'	: 'sulfate aerosol optical '\
						  'depth'	},
			'dust_aod'		: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('dust', d2+'f4')],
				'long_name'	: 'dust aerosol optical depth'},
			'smoke_aod'		: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('smoke', d2+'f4')],
				'long_name'	: 'smoke aerosol optical '\
						  'depth'},
			'seasalt_aod'		: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('seasalt', d2+'f4')],
				'long_name'	: 'seasalt aerosol optical '\
						  'depth'	},
			'blackcarbon_aod'	: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('blackcarbon', d2+'f4')],
				'long_name'	: 'blackcarbon aerosol optical'\
						  ' depth'	},
			'organicmatter_aod'	: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('organicmatter', d2+'f4')],
				'long_name'	: 'organicmatter aerosol '\
						  'optical depth'	},
			'organiccarbon_aod'	: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('organiccarbon', d2+'f4')],
				'long_name'	: 'organiccarbon aerosol '\
						  'optical depth'	},
			'coarse_aod'		: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('coarse', d2+'f4')],
				'long_name'	: 'coarse mode aerosol '\
						  'optical depth'	},
			'fine_aod'		: {
				'dims'		: ('lat','lon',),
				'shape'		: (ny,nx,),
				'units'		: '',
				'dtype'		: [('fine', d2+'f4')],
				'long_name'	: 'fine mode aerosol '\
						  'optical depth'	},
		}
	return vars

def conc_vars( nspec, nz, ny, nx ):
	d4 = str( nspec * nz * ny * nx )
	d3 = str( nz * ny * nx )
	d3s = str( nspec * ny * nx )
	d2 = str( ny * nx )
	vars	= {	'conc'		: {
				'dims'		: ('species','sigma',
						'lat','lon'),
				'shape'		: (nspec,nz,ny,nx),
				'units'		: 'ask_Peng',
###				'units'		: 'ug cm-3',
				'dtype'		: [('conc', d4+'f4')],
				'long_name'	: 'aerosol concentration' },
			'lat'		: {
				'dims'		: ('lat',),
				'shape' 	: (ny,),
				'units'		: 'degrees_north',
				'dtype'		:  [('lat', str(ny)+'f4')],
				'long_name'	: 'latitude'},
			'lon'		: {
				'dims'		: ('lon',),
				'shape' 	: (nx,),
				'units'		: 'degrees_east',
				'dtype'		: [('lon', str(nx) + 'f4')],
				'long_name'	: 'longitude'},
			'sigma'		: {
				'dims'		: ('sigma_staggered',),
				'shape'		: (2*(nz+1),),
				'units'		: 'unitless',
				'dtype'		:  [('sig_a', str(nz+1)+'f4'),\
						('sig_b', str(nz+1)+'f4')],
				'long_name'	: 'top sigma level'},
			'sig_a'		: {
				'dims'		: ('sigma_staggered',),
				'shape'		: (nz+1,),
				'units'		: 'unitless',
				'dtype'		: [('sig_a', str(nz+1) + 'f4')],
				'long_name'	: 'top sigma level'},
			'sig_b'		: {
				'dims'		: ('sigma_staggered',),
				'shape'		: (nz+1,),
				'units'		: 'unitless',
				'dtype'		: [('sig_b', str(nz+1) + 'f4')],
				'long_name'	: 'staggered sigma levels'},
			'height'	: {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'long_name' 	: 'terrain height',
				'dtype'		: [('height',d2 + 'f4')],
				'units'		: 'meters'},	
			'binrad'	: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: '',
				'dtype'		: [('binrad', str(nspec)+'f4')],
				'long_name'	: 'centers of aerosol bins'}, 
			'binradw'	: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: '',
				'dtype'		: [('binradw',str(nspec)+'f4')],
				'long_name'	: 'widths of aerosol size bins'},
			'rho'		: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: 'g cm-3 (particle) or g ' \
						+ 'mol-1 (gas)',
				'dtype'		: [('rho',str(nspec)+'f4')],
				'long_name'	: 'density (particles) or ' + \
						  'molecular weight (gases)'},
			'refract_r'	: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: '',
				'dtype'		:  [('refract_r',str(nspec) \
						+'f4')],
				'long_name'	:'refractive index, real part'},
			'refract_i'	: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: '',
				'dtype'		: [('refract_i',str(nspec) \
						+ 'f4')],
				'long_name'	: 'refractive index, ' \
						+ 'imaginary part'},
			'budget_vars'	: {
				'dims'		: ('budget',),
				'shape'		: (15,),
				'units'		: '',
				'dtype'		: [('budget_vars','15f4')],
				'long_name'	: 'NAAPS metadata ' \
						+ '(see output.f)'},
			'mix'		: {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'm',
				'dtype'		:  [('mix',d2 + 'f4')],
				'long_name' 	: 'mixing length'},
			'lift'		: { 
				'dims'		: ('species','lat','lon'),
				'shape'		: (nspec,ny,nx),
				'long_name' 	: 'source (emitted/lifted)',
				'dtype'		: [('lift',d3s + 'f4')],
				'units'		: 'kg m-2'},
			'sinkd'		: { 
				'dims'		: ('species','lat','lon'),
				'shape'		: (nspec,ny,nx),
				'long_name' 	: 'dry deposition',
				'dtype'		: [('sinkd',d3s + 'f4')],
				'units'		: 'kg m-2, monthly cum'},
			'sinkw'		: {
				'dims'		: ('species','lat','lon'),
				'shape'		: (nspec,ny,nx),
				'long_name' 	: 'wet deposition',
				'dtype'		: [('sinkw', d3s + 'f4')],
				'units'		: 'kg m-2, monthly cum'},
			'temperature'	: {
				'dims'		: ('sigma','lat','lon'),
				'shape'		: (nz,ny,nx),
				'dtype'		: [('temperature', d3 + 'f4')],
				'units'		: 'K',
				'long_name'	: 'temperature'},	
			'sfc_pres'	: {
				'dims'		: ('lat','lon'),
				'shape' 	: (ny,nx),
				'dtype'		: [('sfc_pres',d2 + 'f4')],
				'long_name' 	: 'sea level pressure',
				'units'		: 'hPa' },
		}
	order = ['lat', 'lon', 'sigma', 'height',
		'binrad', 'binradw', 'rho', 'refract_r', 'refract_i', 
		'budget_vars', 'conc', 'mix', 'lift', 'sinkd', 'sinkw',
		'temperature', 'sfc_pres' ]
	return vars, order

def conc_vars_ncdf( nspec, nz, ny, nx ):
	d4 = str( nspec * nz * ny * nx )
	d3 = str( nz * ny * nx )
	d3s = str( nspec * ny * nx )
	d2 = str( ny * nx )
	return {	'conc'		: {
				'dims'		: ('species','sigma',
						'lat','lon'),
				'shape'		: (nspec,nz,ny,nx),
				'units'		: 'ask_Peng',
###				'units'		: 'ug cm-3',
				'dtype'		: [('conc', d4+'f4')],
				'long_name'	: 'aerosol concentration' },
			'lat'		: {
				'dims'		: ('lat',),
				'shape' 	: (ny,),
				'units'		: 'degrees_north',
				'dtype'		:  [('lat', str(ny)+'f4')],
				'long_name'	: 'latitude'},
			'lon'		: {
				'dims'		: ('lon',),
				'shape' 	: (nx,),
				'units'		: 'degrees_east',
				'dtype'		: [('lon', str(nx) + 'f4')],
				'long_name'	: 'longitude'},
			'sigma'		: {
				'dims'		: ('sigma_staggered',),
				'shape'		: (2*(nz+1),),
				'units'		: 'unitless',
				'dtype'		:  [('sig_a', str(nz+1)+'f4'),\
						('sig_b', str(nz+1)+'f4')],
				'long_name'	: 'top sigma level'},
			'sig_a'		: {
				'dims'		: ('sigma_staggered',),
				'shape'		: (nz+1,),
				'units'		: 'unitless',
				'dtype'		: [('sig_a', str(nz+1) + 'f4')],
				'long_name'	: 'top sigma level'},
			'sig_b'		: {
				'dims'		: ('sigma_staggered',),
				'shape'		: (nz+1,),
				'units'		: 'unitless',
				'dtype'		: [('sig_b', str(nz+1) + 'f4')],
				'long_name'	: 'staggered sigma levels'},
			'terrain'	: {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'long_name' 	: 'terrain height',
				'dtype'		: [('height',d2 + 'f4')],
				'units'		: 'meters'},	
			'radius'	: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: '',
				'dtype'		: [('binrad', str(nspec)+'f4')],
				'long_name'	: 'centers of aerosol bins'}, 
			'radius_width'	: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: '',
				'dtype'		: [('binradw',str(nspec)+'f4')],
				'long_name'	: 'widths of aerosol size bins'},
			'rho'		: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: 'g cm-3 (particle) or g ' \
						+ 'mol-1 (gas)',
				'dtype'		: [('rho',str(nspec)+'f4')],
				'long_name'	: 'density (particles) or ' + \
						  'molecular weight (gases)'},
			'real_refractive_index'	: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: '',
				'dtype'		:  [('refract_r',str(nspec) \
						+'f4')],
				'long_name'	:'refractive index, real part'},
			'imaginary_refractive_index'	: {
				'dims'		: ('species',),
				'shape'		: (nspec,),
				'units'		: '',
				'dtype'		: [('refract_i',str(nspec) \
						+ 'f4')],
				'long_name'	: 'refractive index, ' \
						+ 'imaginary part'},
			'budget'	: {
				'dims'		: ('budget',),
				'shape'		: (15,),
				'units'		: '',
				'dtype'		: [('budget_vars','15f4')],
				'long_name'	: 'NAAPS metadata ' \
						+ '(see output.f)'},
			'mixing_coefficients'	: {
				'dims'		: ('lat','lon'),
				'shape'		: (ny,nx),
				'units'		: 'm',
				'dtype'		:  [('mix',d2 + 'f4')],
				'long_name' 	: 'mixing length'},
			'source'		: { 
				'dims'		: ('species','lat','lon'),
				'shape'		: (nspec,ny,nx),
				'long_name' 	: 'source (emitted/lifted)',
				'dtype'		: [('lift',d3s + 'f4')],
				'units'		: 'kg m-2'},
			'sink_dry'		: { 
				'dims'		: ('species','lat','lon'),
				'shape'		: (nspec,ny,nx),
				'long_name' 	: 'dry deposition',
				'dtype'		: [('sinkd',d3s + 'f4')],
				'units'		: 'kg m-2, monthly cum'},
			'sink_wet'		: {
				'dims'		: ('species','lat','lon'),
				'shape'		: (nspec,ny,nx),
				'long_name' 	: 'wet deposition',
				'dtype'		: [('sinkw', d3s + 'f4')],
				'units'		: 'kg m-2, monthly cum'},
			'temperature'	: {
				'dims'		: ('sigma','lat','lon'),
				'shape'		: (nz,ny,nx),
				'dtype'		: [('temperature', d3 + 'f4')],
				'units'		: 'K',
				'long_name'	: 'temperature'},	
			'surface_pressure'	: {
				'dims'		: ('lat','lon'),
				'shape' 	: (ny,nx),
				'dtype'		: [('sfc_pres',d2 + 'f4')],
				'long_name' 	: 'sea level pressure',
				'units'		: 'hPa' },
		}

def regions():
        '''
        Returns a dictionary containing the regions 
        and necessary information to plot ICAP specific data.
        '''
        return {	'global'        : {     'corn'  : [-90,90,-180,180],
                                                'grid'  : [-80,81,-180,181],
                                                'delta' : 20,
                                                'subreg': 0 },
                        'byzantium'     : {     'corn'  : [-5,65,-20,80],
                                                'grid'  : [-5,65,-20,81],
                                                'delta' : 10,
                                                'subreg': 1 },
                        'hs3_2013'    : {       'corn'  : [-5,60,-100,80],
                                                'grid'  : [-5,61,-100,81],
                                                'delta' : 20,
                                                'subreg': 1 },
                        'hs3_2013b'    : {      'corn'  : [-5,60,-100,20],
                                                'grid'  : [-5,61,-100,21],
                                                'delta' : 20,
                                                'subreg': 1 },
                        'subtropatl'    : {     'corn'  : [-5,60,-100,30],
                                                'grid'  : [-5,61,-100,31],
                                                'delta' : 10,
                                                'subreg': 1 },
                        'hs3_2013c'    : {      'corn'  : [0,45,-100,-10],
                                                'grid'  : [0,46,-100,-9],
                                                'delta' : 20,
                                                'subreg': 1 },
                        'niosea'        : {     'corn'  : [-15,35,40,130],
                                                'grid'  : [-15,36,40,131],
                                                'delta' : 5,
                                                'subreg': 1 },
                        'eastasia'      : {     'corn'  : [15,75,70,170],
                                                'grid'  : [15,76,70,171],
                                                'delta' : 10,
                                                'subreg': 1 },
                        'pacific'       : {     'corn'  : [15,80,90,270],
                                                'grid'  : [15,81,90,271],
                                                'delta' : 10,
                                                'subreg': 1 },
                        'conus'         : {     'corn'  : [0,65,-150,-50],
                                                'grid'  : [0,66,-150,-49],
                                                'delta' : 10,
                                                'subreg': 1 },
                        'satlantic'     : {     'corn'  : [-60,10,-90,60],
                                                'grid'  : [-60,11,-90,61],
                                                'delta' : 10,
                                                'subreg': 1 },
                        'sioaus'        : {     'corn'  : [-60,10,0,180],
                                                'grid'  : [-60,11,0,181],
                                                'delta' : 10,
                                                'subreg': 1 },
			#_The .1 is to make sub_region not clip the data
                        'npolar'        : {     'corn'  : [0 , 90,-180,180.1],
                                                'grid'  : [45, 90,-180,181],
                                                'delta' : 15,
                                                'subreg': 1 }
                }


def aeronet_modes():
	return {        'total' : { 'color' : 'black' },
                        'fine'  : { 'color' : 'green' },
                        'coarse' : { 'color' : 'blue' } }

def site2code():
	''' produce a dict to get code by site name '''
	out = {}
	for c, m in aeronet_points().iteritems(): out.update({ m[1] : c })
	return out

def aeronet_points( code=None, **kwargs ):
	sites = {
		'armbar' : [[  -70.29,   41.67], 'ARM_Barnstable_MA'], 
		'armdar' : [[  130.89,  -12.43], 'ARM_Darwin'], 
		'armgan' : [[   73.15,   -0.69], 'ARM_Gan_Island'], 
		'armhig' : [[  -70.05,   42.03], 'ARM_Highlands_MA'], 
		'athens' : [[   23.77,   37.99], 'ATHENS-NOA'], 
		'agoufo' : [[   -1.48,   15.35], 'Agoufou'], 
		'altafl' : [[  -56.10,   -9.87], 'Alta_Floresta'], 
		'amesss' : [[  -93.77,   42.02], 'Ames'], 
		'amster' : [[   77.57,  -37.81], 'Amsterdam_Island'], 
		'andene' : [[   16.01,   69.28], 'Andenes'], 
		'antarc' : [[  123.30,  -75.08], 'AntarcticaDomeC'], 
		'appala' : [[  -81.70,   36.20], 'Appalachian_State'], 
		'appled' : [[  -70.62,   42.99], 'Appledore_Island'], 
		'apraha' : [[  144.66,   13.42], 'Apra_Harbor'], 
		'arcach' : [[   -1.16,   44.66], 'Arcachon'], 
		'aricaa' : [[  -70.31,  -18.47], 'Arica'], 
		'ascens' : [[  -14.41,   -7.98], 'Ascension_Island'], 
		'aubier' : [[    3.11,   45.76], 'Aubiere_LAMP'], 
		'autill' : [[   -4.60,   42.00], 'Autilla'], 
		'avigno' : [[    4.88,   43.93], 'Avignon'], 
		'bondvi' : [[  -88.37,   40.05], 'BONDVILLE'], 
		'bsrnba' : [[ -105.01,   40.05], 'BSRN_BAO_Boulder'], 
		'baclie' : [[  105.73,    9.28], 'Bac_Lieu'], 
		'bachlo' : [[  107.73,   20.13], 'Bach_Long_Vi'], 
		'badajo' : [[   -7.01,   38.88], 'Badajoz'], 
		'baegry' : [[  124.63,   37.97], 'Baegryung_SuperSite'], 
		'baengn' : [[  124.63,   37.97], 'Baengnyeong'], 
		'bambey' : [[  -16.48,   14.71], 'Bambey-ISRA'], 
		'bandun' : [[  107.61,   -6.89], 'Bandung'], 
		'banizo' : [[    2.66,   13.54], 'Banizoumbou'], 
		'barbad' : [[  -59.62,   13.15], 'Barbados'], 
		'barcel' : [[    2.12,   41.39], 'Barcelona'], 
		'bariun' : [[   16.88,   41.11], 'Bari_University'], 
		'barrow' : [[ -156.66,   71.31], 'Barrow'], 
		'bayfor' : [[   -0.10,   51.78], 'Bayfordbury'], 
		'beijin' : [[  116.38,   39.98], 'Beijing'], 
		'belskk' : [[   20.79,   51.84], 'Belsk'], 
		'bholaa' : [[   90.75,   22.17], 'Bhola'], 
		'biller' : [[  -71.27,   42.53], 'Billerica'], 
		'birdsv' : [[  139.35,  -25.90], 'Birdsville'], 
		'birken' : [[    8.25,   58.39], 'Birkenes'], 
		'blidaa' : [[    2.88,   36.51], 'Blida'], 
		'bolzan' : [[   11.33,   46.46], 'Bolzano'], 
		'bonanz' : [[ -148.32,   64.74], 'Bonanza_Creek'], 
		'bordjb' : [[    0.95,   21.33], 'Bordj_Badji_Mokhtar'], 
		'boulde' : [[ -105.25,   40.02], 'Boulder'], 
		'bozema' : [[ -111.05,   45.67], 'Bozeman'], 
		'bratts' : [[ -104.70,   50.28], 'Bratts_Lake'], 
		'brisba' : [[  153.01,  -27.50], 'Brisbane-Uni_of_QLD'], 
		'brookh' : [[  -72.89,   40.87], 'Brookhaven'], 
		'brusse' : [[    4.35,   50.78], 'Brussels'], 
		'buchar' : [[   26.03,   44.35], 'Bucharest_Inoe'], 
		'buesum' : [[    8.88,   54.13], 'Buesum'], 
		'bureop' : [[    5.50,   48.56], 'Bure_OPE'], 
		'burjas' : [[   -0.42,   39.51], 'Burjassot'], 
		'cartel' : [[  -71.93,   45.38], 'CARTEL'], 
		'cartsi' : [[  -97.49,   36.61], 'CART_SITE'], 
		'casleo' : [[  -69.31,  -31.80], 'CASLEO'], 
		'ccnyyy' : [[  -73.95,   40.82], 'CCNY'], 
		'ceilaa' : [[  -58.50,  -34.57], 'CEILAP-BA'], 
		'clujub' : [[   23.55,   46.77], 'CLUJ_UBB'], 
		'coveee' : [[  -75.71,   36.90], 'COVE'], 
		'covese' : [[  -75.71,   36.90], 'COVE_SEAPRISM'], 
		'crpsmm' : [[   40.19,   -3.00], 'CRPSM_Malindi'], 
		'cuiaba' : [[  -56.02,  -15.73], 'CUIABA-MIRANDA'], 
		'cut-te' : [[   33.04,   34.67], 'CUT-TEPAK'], 
		'cabauw' : [[    4.93,   51.97], 'Cabauw'], 
		'caboda' : [[   -9.50,   38.78], 'Cabo_da_Roca'], 
		'cacere' : [[   -6.34,   39.48], 'Caceres'], 
		'cairoe' : [[   31.29,   30.08], 'Cairo_EMA'], 
		'cairoe' : [[   31.29,   30.08], 'Cairo_EMA_2'], 
		'caltec' : [[ -118.13,   34.14], 'CalTech'], 
		'calern' : [[    6.93,   43.75], 'Calern_OCA'], 
		'calhau' : [[  -24.87,   16.86], 'Calhau'], 
		'camagu' : [[  -77.85,   21.42], 'Camaguey'], 
		'campog' : [[  -54.54,  -20.44], 'Campo_Grande_SONDA'], 
		'canber' : [[  149.11,  -35.27], 'Canberra'], 
		'capesa' : [[  -65.62,   18.38], 'Cape_San_Juan'], 
		'capove' : [[  -22.94,   16.73], 'Capo_Verde'], 
		'carpen' : [[    5.06,   44.08], 'Carpentras'], 
		'cartsi' : [[  -97.49,   36.61], 'Cart_Site'], 
		'cartel' : [[  -71.93,   45.38], 'Cartel_X'], 
		'cerrop' : [[   -3.49,   37.11], 'Cerro_Poyos'], 
		'chapai' : [[  -74.98,   49.82], 'Chapais'], 
		'chen-k' : [[  120.22,   23.00], 'Chen-Kung_Univ'], 
		'chiang' : [[   98.97,   18.77], 'Chiang_Mai_Met_Sta'], 
		'chibau' : [[  140.10,   35.62], 'Chiba_University'], 
		'chilbo' : [[   -1.44,   51.14], 'Chilbolton'], 
		'church' : [[  -93.82,   58.74], 'Churchill'], 
		'ciutad' : [[    3.84,   39.99], 'Ciutadella_Menorca'], 
		'cordob' : [[  -64.46,  -31.52], 'Cordoba-CETT'], 
		'coruna' : [[   -8.42,   43.36], 'Coruna'], 
		'cretei' : [[    2.44,   48.79], 'Creteil'], 
		'crozet' : [[   51.85,  -46.43], 'Crozet_Island'], 
		'dmnmai' : [[   12.02,   13.22], 'DMN_Maine_Soroa'], 
		'dakarr' : [[  -16.96,   14.39], 'Dakar'], 
		'dalanz' : [[  104.42,   43.58], 'Dalanzadgad'], 
		'darwin' : [[  130.89,  -12.42], 'Darwin'], 
		'davoss' : [[    9.84,   46.81], 'Davos'], 
		'dayton' : [[  -84.11,   39.78], 'Dayton'], 
		'dhadna' : [[   56.32,   25.51], 'Dhadnah'], 
		'dhakau' : [[   90.40,   23.73], 'Dhaka_University'], 
		'doiang' : [[   99.05,   19.93], 'Doi_Ang_Khang'], 
		'dongsh' : [[  116.73,   20.70], 'Dongsha_Island'], 
		'dunker' : [[    2.37,   51.04], 'Dunkerque'], 
		'dushan' : [[   68.86,   38.55], 'Dushanbe'], 
		'epa-nc' : [[  121.19,   24.97], 'EPA-NCU'], 
		'etnaaa' : [[   15.02,   37.61], 'ETNA'], 
		'evk2-c' : [[   86.81,   27.96], 'EVK2-CNR'], 
		'easton' : [[  -76.07,   38.81], 'Easton_Airport'], 
		'edinbu' : [[   -3.18,   55.92], 'Edinburgh'], 
		'eforie' : [[   28.63,   44.08], 'Eforie'], 
		'egbert' : [[  -79.75,   44.23], 'Egbert'], 
		'egbert' : [[  -79.75,   44.23], 'Egbert_X'], 
		'eilatt' : [[   34.92,   29.50], 'Eilat'], 
		'elaren' : [[   -6.73,   37.10], 'El_Arenosillo'], 
		'elnido' : [[  119.41,   11.21], 'El_Nido_Airport'], 
		'elsegu' : [[ -118.38,   33.91], 'El_Segundo'], 
		'elands' : [[   29.42,  -26.25], 'Elandsfontein'], 
		'ersaaa' : [[    9.36,   43.00], 'Ersa'], 
		'etosha' : [[   15.91,  -19.18], 'Etosha_Pan'], 
		'evoraa' : [[   -7.91,   38.57], 'Evora'], 
		'forthc' : [[   25.28,   35.33], 'FORTH_CRETE'], 
		'fzj-jo' : [[    6.41,   50.91], 'FZJ-JOYCE'], 
		'farmin' : [[ -108.48,   36.80], 'Farmington_RSVP'], 
		'fortmc' : [[ -111.48,   56.75], 'Fort_McMurray'], 
		'french' : [[ -115.93,   36.81], 'Frenchman_Flat'], 
		'fresno' : [[ -119.77,   36.78], 'Fresno'], 
		'fresno' : [[ -119.77,   36.79], 'Fresno_2'], 
		'frioul' : [[    5.29,   43.27], 'Frioul'], 
		'fukuee' : [[  128.68,   32.75], 'Fukue'], 
		'fukuok' : [[  130.47,   33.52], 'Fukuoka'], 
		'gotsea' : [[  101.41,    9.29], 'GOT_Seaprism'], 
		'gsfccc' : [[  -76.84,   38.99], 'GSFC'], 
		'gageoc' : [[  124.59,   33.94], 'Gageocho_Station'], 
		'gandhi' : [[   84.13,   25.87], 'Gandhi_College'], 
		'gangne' : [[  128.87,   37.77], 'Gangneung_WNU'], 
		'georgi' : [[  -84.40,   33.78], 'Georgia_Tech'], 
		'gloria' : [[   29.36,   44.60], 'Gloria'], 
		'goldst' : [[ -116.79,   35.23], 'Goldstone'], 
		'gorong' : [[   34.35,  -18.98], 'Gorongosa'], 
		'gosans' : [[  126.16,   33.29], 'Gosan_SNU'], 
		'gozooo' : [[   14.26,   36.03], 'Gozo'], 
		'gracio' : [[  -28.03,   39.09], 'Graciosa'], 
		'granad' : [[   -3.60,   37.16], 'Granada'], 
		'grandf' : [[  -97.08,   47.93], 'Grand_Forks'], 
		'guadel' : [[  -61.50,   16.33], 'Guadeloup'], 
		'gustav' : [[   17.47,   58.59], 'Gustav_Dalen_Tower'], 
		'gwangj' : [[  126.84,   35.23], 'Gwangju_GIST'], 
		'gwangj' : [[  126.84,   35.23], 'Gwangju_K-JIST'], 
		'hjandr' : [[ -122.22,   44.24], 'HJAndrews'], 
		'hadael' : [[   39.73,   21.80], 'Hada_El-Sham'], 
		'halifa' : [[  -63.59,   44.64], 'Halifax'], 
		'hambur' : [[    9.97,   53.57], 'Hamburg'], 
		'hankuk' : [[  127.27,   37.34], 'Hankuk_UFS'], 
		'harvar' : [[  -72.19,   42.53], 'Harvard_Forest'], 
		'helgol' : [[    7.89,   54.18], 'Helgoland'], 
		'helsin' : [[   24.96,   60.20], 'Helsinki'], 
		'helsin' : [[   24.93,   59.95], 'Helsinki_Lighthouse'], 
		'hentie' : [[   14.26,  -22.10], 'Henties_Bay'], 
		'hermos' : [[ -110.96,   29.07], 'Hermosillo'], 
		'hongko' : [[  114.26,   22.21], 'Hong_Kong_Hok_Tsui'], 
		'hongko' : [[  114.18,   22.30], 'Hong_Kong_PolyU'], 
		'hongko' : [[  114.12,   22.48], 'Hong_Kong_Sheung'], 
		'hornsu' : [[   15.56,   77.00], 'Hornsund'], 
		'huelva' : [[   -6.57,   37.02], 'Huelva'], 
		'hyytia' : [[   24.30,   61.85], 'Hyytiala'], 
		'iasbss' : [[   48.57,   36.66], 'IASBS'], 
		'icipe-' : [[   34.20,   -0.42], 'ICIPE-Mbita'], 
		'iercin' : [[   -5.93,   13.28], 'IER_Cinzana'], 
		'ift-le' : [[   12.44,   51.35], 'IFT-Leipzig'], 
		'imaapo' : [[   15.72,   40.60], 'IMAA_Potenza'], 
		'ims-me' : [[   34.26,   36.56], 'IMS-METU-ERDEMLI'], 
		'iasilo' : [[   27.56,   47.19], 'Iasi_LOASL'], 
		'ilorin' : [[    4.34,    8.32], 'Ilorin'], 
		'iqalui' : [[  -68.54,   63.75], 'Iqaluit'], 
		'irkuts' : [[  103.09,   51.80], 'Irkutsk'], 
		'ispraa' : [[    8.63,   45.80], 'Ispra'], 
		'issyk-' : [[   76.98,   42.62], 'Issyk-Kul'], 
		'ittoqq' : [[  -21.95,   70.48], 'Ittoqqortoormiit'], 
		'izanaa' : [[  -16.50,   28.31], 'Izana'], 
		'jabiru' : [[  132.89,  -12.66], 'Jabiru'], 
		'jaipur' : [[   75.81,   26.91], 'Jaipur'], 
		'jambii' : [[  103.64,   -1.63], 'Jambi'], 
		'jipara' : [[  -62.85,  -10.93], 'Ji_Parana_SE'], 
		'jomsom' : [[   83.71,   28.78], 'Jomsom'], 
		'kaustc' : [[   39.10,   22.30], 'KAUST_Campus'], 
		'konzae' : [[  -96.61,   39.10], 'KONZA_EDC'], 
		'kanger' : [[  -50.62,   67.00], 'Kangerlussuaq'], 
		'kanpur' : [[   80.23,   26.51], 'Kanpur'], 
		'kanzel' : [[   13.91,   46.68], 'Kanzelhohe_Obs'], 
		'karach' : [[   67.03,   24.87], 'Karachi'], 
		'karlsr' : [[    8.43,   49.09], 'Karlsruhe'], 
		'kathma' : [[   85.39,   27.68], 'Kathmandu-Bode'], 
		'kathma' : [[   85.54,   27.60], 'Kathmandu_Univ'], 
		'kellog' : [[  -85.37,   42.41], 'Kellogg_LTER'], 
		'kelown' : [[ -119.37,   49.96], 'Kelowna'], 
		'kelown' : [[ -119.40,   49.94], 'Kelowna_UAS'], 
		'keybis' : [[  -80.16,   25.73], 'Key_Biscayne'], 
		'keybis' : [[  -80.16,   25.73], 'Key_Biscayne2'], 
		'kobeee' : [[  135.29,   34.72], 'Kobe'], 
		'konzaa' : [[  -96.56,   39.08], 'Konza'], 
		'koreau' : [[  127.03,   37.59], 'Korea_University'], 
		'kuchin' : [[  110.35,    1.49], 'Kuching'], 
		'kuopio' : [[   27.63,   62.89], 'Kuopio'], 
		'kuujju' : [[  -77.80,   55.30], 'Kuujjuarapik'], 
		'kuwait' : [[   47.97,   29.32], 'Kuwait_University'], 
		'kyivvv' : [[   30.50,   50.36], 'Kyiv'], 
		'kyiv-a' : [[   30.50,   50.45], 'Kyiv-AO'], 
		'kyungi' : [[  128.82,   36.07], 'Kyungil_University'], 
		'liscoo' : [[  -73.34,   40.95], 'LISCO'], 
		'lsuuuu' : [[  -91.18,   30.41], 'LSU'], 
		'lajoll' : [[ -117.25,   32.87], 'La_Jolla'], 
		'lalagu' : [[  -16.32,   28.48], 'La_Laguna'], 
		'laparg' : [[  -67.05,   17.97], 'La_Parguera'], 
		'lapazz' : [[  -68.07,  -16.54], 'La_Paz'], 
		'laeger' : [[    8.35,   47.48], 'Laegeren'], 
		'lahore' : [[   74.32,   31.54], 'Lahore'], 
		'lakear' : [[  128.75,  -16.11], 'Lake_Argyle'], 
		'lakele' : [[  121.70,  -31.25], 'Lake_Lefroy'], 
		'lamped' : [[   12.63,   35.52], 'Lampedusa'], 
		'lasgal' : [[  -16.65,   28.02], 'Las_Galletas'], 
		'lecceu' : [[   18.11,   40.34], 'Lecce_University'], 
		'lillee' : [[    3.14,   50.61], 'Lille'], 
		'litang' : [[  100.26,   29.98], 'Litang'], 
		'london' : [[   -0.13,   51.52], 'London-UCL-UAO'], 
		'loskop' : [[   29.35,  -25.41], 'Loskop_Dam'], 
		'luangn' : [[  101.42,   20.93], 'Luang_Namtha'], 
		'lucind' : [[  146.39,  -18.52], 'Lucinda'], 
		'lugans' : [[   39.36,   48.57], 'Lugansk'], 
		'lulinn' : [[  120.87,   23.47], 'Lulin'], 
		'lumbin' : [[   83.28,   27.49], 'Lumbini'], 
		'mco-ha' : [[   73.18,    6.78], 'MCO-Hanimaadhoo'], 
		'mdscie' : [[  -76.62,   39.28], 'MD_Science_Center'], 
		'mvcooo' : [[  -70.55,   41.30], 'MVCO'], 
		'madrid' : [[   -3.72,   40.45], 'Madrid'], 
		'mainzz' : [[    8.30,   50.00], 'Mainz'], 
		'malaga' : [[   -4.48,   36.72], 'Malaga'], 
		'manaus' : [[  -59.97,   -2.89], 'Manaus_EMBRAPA'], 
		'manila' : [[  121.08,   14.64], 'Manila_Observatory'], 
		'manuss' : [[  147.43,   -2.06], 'Manus'], 
		'marbel' : [[   -4.99,   36.49], 'Marbella_San_Pedro'], 
		'marico' : [[ -111.97,   33.07], 'Maricopa'], 
		'masdar' : [[   54.65,   24.43], 'Masdar_Institute'], 
		'maunal' : [[ -155.58,   19.54], 'Mauna_Loa'], 
		'mcclel' : [[ -121.40,   38.67], 'McClellan_AFB'], 
		'medell' : [[  -74.08,    4.64], 'Medellin'], 
		'merred' : [[  118.00,  -31.50], 'Merredin'], 
		'messin' : [[   15.57,   38.20], 'Messina'], 
		'mexico' : [[  -99.18,   19.33], 'Mexico_City'], 
		'mezair' : [[   53.78,   23.14], 'Mezaira'], 
		'miamii' : [[  -80.28,   25.72], 'Miami'], 
		'midway' : [[ -177.38,   28.21], 'Midway_Island'], 
		'milyer' : [[  113.93,  -22.03], 'Milyering'], 
		'minskk' : [[   27.60,   53.92], 'Minsk'], 
		'missou' : [[ -114.08,   46.92], 'Missoula'], 
		'modena' : [[   10.95,   44.63], 'Modena'], 
		'moldov' : [[   28.82,   47.00], 'Moldova'], 
		'monguu' : [[   23.15,  -15.25], 'Mongu'], 
		'monter' : [[ -121.85,   36.59], 'Monterey'], 
		'montes' : [[    9.44,   42.67], 'Montesoro_Bastia'], 
		'montse' : [[    0.73,   42.05], 'Montsec'], 
		'moscow' : [[   37.51,   55.70], 'Moscow_MSU_MO'], 
		'mukdah' : [[  104.68,   16.61], 'Mukdahan'], 
		'munich' : [[   11.57,   48.15], 'Munich_University'], 
		'murcia' : [[   -1.17,   38.00], 'Murcia'], 
		'mussaf' : [[   54.47,   24.37], 'Mussafa'], 
		'muztag' : [[   74.95,   38.36], 'Muztagh_Ata'], 
		'namcoo' : [[   90.96,   30.77], 'NAM_CO'], 
		'nasala' : [[  -76.38,   37.10], 'NASA_LaRC'], 
		'ncutai' : [[  121.19,   24.97], 'NCU_Taiwan'], 
		'ndmarb' : [[  124.84,    6.50], 'ND_Marbel_Univ'], 
		'neon-b' : [[ -105.27,   40.01], 'NEON-Boulder'], 
		'neoncv' : [[ -105.17,   40.16], 'NEON_CVALLA'], 
		'nghiad' : [[  105.80,   21.05], 'NGHIA_DO'], 
		'nuistt' : [[  118.72,   32.21], 'NUIST'], 
		'nainit' : [[   79.46,   29.36], 'Nainital'], 
		'nairob' : [[   36.87,   -1.34], 'Nairobi'], 
		'naraaa' : [[  135.83,   34.69], 'Nara'], 
		'nauruu' : [[  166.92,   -0.52], 'Nauru'], 
		'neszio' : [[   34.79,   31.92], 'Nes_Ziona'], 
		'nhatra' : [[  109.21,   12.20], 'NhaTrang'], 
		'nyalsu' : [[   11.86,   78.93], 'Ny_Alesund'], 
		'notooo' : [[  137.14,   37.33], 'Noto'], 
		'ohpobs' : [[    5.71,   43.94], 'OHP_OBSERVATOIRE'], 
		'opalll' : [[  -85.94,   79.99], 'OPAL'], 
		'oosten' : [[    2.92,   51.23], 'Oostende'], 
		'osakaa' : [[  135.59,   34.65], 'Osaka'], 
		'osaka-' : [[  135.51,   34.77], 'Osaka-North'], 
		'ouarza' : [[   -6.91,   30.93], 'Ouarzazate'], 
		'oujdaa' : [[   -2.48,   35.08], 'Oujda'], 
		'panama' : [[  -79.00,    9.00], 'Panama_BCI'], 
		'pearll' : [[  -86.42,   80.05], 'PEARL'], 
		'palais' : [[    2.21,   48.70], 'Palaiseau'], 
		'palang' : [[  113.95,   -2.23], 'Palangkararya'], 
		'palang' : [[  113.95,   -2.23], 'Palangkaraya'], 
		'palenc' : [[   -4.52,   41.99], 'Palencia'], 
		'palgru' : [[   13.15,   58.76], 'Palgrunden'], 
		'palmad' : [[    2.63,   39.55], 'Palma_de_Mallorca'], 
		'pariss' : [[    2.33,   48.87], 'Paris'], 
		'petrol' : [[  -40.50,   -9.38], 'Petrolina_SONDA'], 
		'pickle' : [[  -90.22,   51.45], 'Pickle_Lake'], 
		'pokhar' : [[   83.97,   28.15], 'Pokhara'], 
		'pontia' : [[  109.19,    0.08], 'Pontianak'], 
		'porque' : [[    6.16,   43.00], 'Porquerolles'], 
		'portov' : [[  -63.95,   -8.77], 'Porto_Velho'], 
		'portov' : [[  -63.94,   -8.84], 'Porto_Velho_UNIR'], 
		'pretor' : [[   28.28,  -25.76], 'Pretoria_CSIR-DPSS'], 
		'puneee' : [[   73.81,   18.54], 'Pune'], 
		'pusann' : [[  129.08,   35.23], 'Pusan_NU'], 
		'qomsca' : [[   86.95,   28.36], 'QOMS_CAS'], 
		'reunio' : [[   55.48,  -20.88], 'REUNION_ST_DENIS'], 
		'ragged' : [[  -59.43,   13.17], 'Ragged_Point'], 
		'railro' : [[ -115.96,   38.50], 'Railroad_Valley'], 
		'redmou' : [[ -107.72,   37.91], 'Red_Mountain_Pass'], 
		'redriv' : [[  106.13,   20.73], 'Red_River_Delta'], 
		'resolu' : [[  -94.90,   74.73], 'Resolute_Bay'], 
		'rimroc' : [[ -116.99,   46.49], 'Rimrock'], 
		'riobra' : [[  -67.87,   -9.96], 'Rio_Branco'], 
		'riodej' : [[  -43.23,  -22.86], 'Rio_de_Janeiro_UFRJ'], 
		'rometo' : [[   12.65,   41.84], 'Rome_Tor_Vergata'], 
		'sagres' : [[   -8.87,   37.05], 'SAGRES'], 
		'santac' : [[  -63.18,  -17.80], 'SANTA_CRUZ'], 
		'sedebo' : [[   34.78,   30.86], 'SEDE_BOKER'], 
		'serccc' : [[  -76.50,   38.88], 'SERC'], 
		'saadaa' : [[   -8.16,   31.63], 'Saada'], 
		'sablei' : [[  -60.01,   43.93], 'Sable_Island'], 
		'salond' : [[    5.12,   43.61], 'Salon_de_Provence'], 
		'sangiu' : [[    9.52,   42.29], 'San_Giuliano'], 
		'sannic' : [[ -119.54,   33.26], 'San_Nicolas_Vandal'], 
		'santac' : [[  -16.25,   28.47], 'Santa_Cruz_Tenerife'], 
		'saomar' : [[  -53.08,  -29.44], 'Sao_Martinho_SONDA'], 
		'saopau' : [[  -46.73,  -23.56], 'Sao_Paulo'], 
		'saturn' : [[ -123.13,   48.78], 'Saturn_Island'], 
		'seouls' : [[  126.95,   37.46], 'Seoul_SNU'], 
		'sevast' : [[   33.52,   44.62], 'Sevastopol'], 
		'sevill' : [[ -106.89,   34.35], 'Sevilleta'], 
		'seysse' : [[    1.26,   43.50], 'Seysses'], 
		'shirah' : [[  135.36,   33.69], 'Shirahama'], 
		'silpak' : [[  100.04,   13.82], 'Silpakorn_Univ'], 
		'singap' : [[  103.78,    1.30], 'Singapore'], 
		'siouxf' : [[  -96.63,   43.74], 'Sioux_Falls'], 
		'skukuz' : [[   31.59,  -24.99], 'Skukuza'], 
		'sodank' : [[   26.63,   67.37], 'Sodankyla'], 
		'solarv' : [[   46.40,   24.91], 'Solar_Village'], 
		'sonlaa' : [[  103.91,   21.33], 'Son_La'], 
		'songkh' : [[  100.60,    7.18], 'Songkhla_Met_Sta'], 
		'southp' : [[   70.30,  -90.00], 'South_Pole_Obs_NOAA'], 
		'steamb' : [[ -106.81,   40.40], 'SteamboatSpring'], 
		'steamb' : [[ -106.82,   40.46], 'Steamboat_Springs'], 
		'tablem' : [[ -117.68,   34.38], 'TABLE_MOUNTAIN_CA'], 
		'tubita' : [[   32.78,   39.89], 'TUBITAK_UZAY_Ankara'], 
		'tabern' : [[   -2.36,   37.09], 'Tabernas_PSA-DLR'], 
		'tablem' : [[ -105.24,   40.12], 'Table_Mountain'], 
		'tahirr' : [[  100.20,    5.41], 'Tahir'], 
		'tahiti' : [[ -149.61,  -17.58], 'Tahiti'], 
		'taipin' : [[  114.36,   10.38], 'Tai_Ping'], 
		'taihuu' : [[  120.22,   31.42], 'Taihu'], 
		'taipei' : [[  121.50,   25.03], 'Taipei_CWB'], 
		'tamanr' : [[    5.53,   22.79], 'Tamanrasset_INM'], 
		'teidee' : [[  -16.64,   28.27], 'Teide'], 
		'thessa' : [[   22.96,   40.63], 'Thessaloniki'], 
		'thomps' : [[  -70.95,   43.11], 'Thompson_Farm'], 
		'thulee' : [[  -68.77,   76.52], 'Thule'], 
		'tiksii' : [[  128.92,   71.59], 'Tiksi'], 
		'timiso' : [[   21.23,   45.75], 'Timisoara'], 
		'tingat' : [[  139.99,  -28.98], 'Tinga_Tingana'], 
		'tiziou' : [[    4.06,   36.70], 'Tizi_Ouzou'], 
		'tomskk' : [[   85.07,   56.48], 'Tomsk'], 
		'torave' : [[   26.46,   58.26], 'Toravere'], 
		'toront' : [[  -79.47,   43.97], 'Toronto'], 
		'toulon' : [[    6.01,   43.14], 'Toulon'], 
		'toulou' : [[    1.37,   43.57], 'Toulouse'], 
		'trelew' : [[  -65.31,  -43.25], 'Trelew'], 
		'trinid' : [[ -124.15,   41.05], 'Trinidad_Head'], 
		'tucson' : [[ -110.95,   32.23], 'Tucson'], 
		'tudorh' : [[  -64.88,   32.26], 'Tudor_Hill'], 
		'tuxtla' : [[  -93.15,   16.75], 'Tuxtla_Gutierrez'], 
		'tuzgol' : [[   33.34,   38.75], 'Tuz_Golu'], 
		'tuzgol' : [[   33.45,   38.84], 'Tuz_Golu_2'], 
		'uahunt' : [[  -86.64,   34.73], 'UAHuntsville'], 
		'ucsbbb' : [[ -119.85,   34.42], 'UCSB'], 
		'uhcoas' : [[  -95.04,   29.39], 'UH_Coastal_Center'], 
		'umbccc' : [[  -76.71,   39.25], 'UMBC'], 
		'umbcte' : [[  -76.71,   39.25], 'UMBC_temp'], 
		'unc-bo' : [[  -74.08,    4.64], 'UNC-Bogota'], 
		'uprmli' : [[  -67.14,   18.21], 'UPRM_Lidar_Lab'], 
		'uscsea' : [[ -118.12,   33.56], 'USC_SEAPRISM'], 
		'usmpen' : [[  100.30,    5.36], 'USM_Penang'], 
		'uofwis' : [[  -89.41,   43.07], 'U_of_Wisconsin_SSEC'], 
		'ubonra' : [[  104.87,   15.25], 'Ubon_Ratchathani'], 
		'univof' : [[  -95.34,   29.72], 'Univ_of_Houston'], 
		'univof' : [[ -112.87,   49.68], 'Univ_of_Lethbridge'], 
		'univof' : [[ -119.81,   39.54], 'Univ_of_Nevada-Reno'], 
		'ussuri' : [[  132.16,   43.70], 'Ussuriysk'], 
		'utstei' : [[   23.33,  -71.95], 'Utsteinen'], 
		'vallad' : [[   -4.71,   41.66], 'Valladolid'], 
		'vallad' : [[   -4.71,   41.66], 'Valladolid_Sci'], 
		'venise' : [[   12.51,   45.31], 'Venise'], 
		'vienti' : [[  102.57,   17.99], 'Vientiane'], 
		'villef' : [[    7.33,   43.68], 'Villefranche'], 
		'wallop' : [[  -75.47,   37.94], 'Wallops'], 
		'waskes' : [[ -106.08,   53.92], 'Waskesiu'], 
		'waveci' : [[  -90.48,   28.87], 'WaveCIS_Site_CSI_6'], 
		'whites' : [[ -106.35,   32.92], 'White_Sands'], 
		'whites' : [[ -106.34,   32.63], 'White_Sands_HELSTF'], 
		'witsun' : [[   28.03,  -26.19], 'Wits_University'], 
		'wytham' : [[   -1.33,   51.77], 'Wytham_Woods'], 
		'xanthi' : [[   24.92,   41.15], 'Xanthi'], 
		'xiangh' : [[  116.96,   39.75], 'XiangHe'], 
		'xinglo' : [[  117.58,   40.40], 'Xinglong'], 
		'yakuts' : [[  129.37,   61.66], 'Yakutsk'], 
		'yekate' : [[   59.55,   57.04], 'Yekaterinburg'], 
		'yellow' : [[ -114.38,   62.45], 'Yellowknife_Aurora'], 
		'yenbai' : [[  104.87,   21.70], 'Yen_Bai'], 
		'yonsei' : [[  126.93,   37.56], 'Yonsei_University'], 
		'yumaaa' : [[ -114.58,   32.64], 'Yuma'], 
		'zarago' : [[   -0.88,   41.63], 'Zaragoza'], 
		'zhongs' : [[  113.39,   23.06], 'Zhongshan_Univ'], 
		'zinder' : [[    8.99,   13.78], 'Zinder_Airport'], 
		'zinder' : [[    8.98,   13.78], 'Zinder_DMN'], 
		'zouera' : [[  -12.48,   22.75], 'Zouerate-Fennec'], }	
	if code==None:
		return sites
	else:
		return sites[code]

def aeronet_points_icap( code=None, **kwargs ):
	''' list of sites to plot for ICAP web page '''
	sites = {
		'altafl' : [[  -56.10,   -9.87], 'Alta_Floresta'], 
		'amster' : [[   77.57,  -37.81], 'Amsterdam_Island'], 
		'andene' : [[   16.01,   69.28], 'Andenes'], 
		'antarc' : [[  123.30,  -75.08], 'AntarcticaDomeC'], 
		'banizo' : [[    2.66,   13.54], 'Banizoumbou'], 
		'barcel' : [[    2.12,   41.39], 'Barcelona'], 
		'barrow' : [[ -156.66,   71.31], 'Barrow'], 
		'beijin' : [[  116.38,   39.98], 'Beijing'], 
		'belskk' : [[   20.79,   51.84], 'Belsk'], 
		'birdsv' : [[  139.35,  -25.90], 'Birdsville'], 
		'blidaa' : [[    2.88,   36.51], 'Blida'], 
		'bonanz' : [[ -148.32,   64.74], 'Bonanza_Creek'], 
		'bozema' : [[ -111.05,   45.67], 'Bozeman'], 
		'bratts' : [[ -104.70,   50.28], 'Bratts_Lake'], 
		'bsrnba' : [[ -105.01,   40.05], 'BSRN_BAO_Boulder'], 
		'cabauw' : [[    4.93,   51.97], 'Cabauw'], 
		'camagu' : [[  -77.85,   21.42], 'Camaguey'], 
		'campog' : [[  -54.54,  -20.44], 'Campo_Grande_SONDA'], 
		'canber' : [[  149.11,  -35.27], 'Canberra'], 
		'capove' : [[  -22.94,   16.73], 'Capo_Verde'], 
		'cartsi' : [[  -97.49,   36.61], 'CART_SITE'], 
		'cartel' : [[  -71.93,   45.38], 'CARTEL'], 
		'ceilaa' : [[  -58.50,  -34.57], 'CEILAP-BA'], 
		'chiang' : [[   98.97,   18.77], 'Chiang_Mai_Met_Sta'], 
		'crozet' : [[   51.85,  -46.43], 'Crozet_Island'], 
		'cordob' : [[  -64.46,  -31.52], 'Cordoba-CETT'], 
		'crpsmm' : [[   40.19,   -3.00], 'CRPSM_Malindi'], 
		'dakarr' : [[  -16.96,   14.39], 'Dakar'], 
		'dalanz' : [[  104.42,   43.58], 'Dalanzadgad'], 
		'dayton' : [[  -84.11,   39.78], 'Dayton'], 
		'dmnmai' : [[   12.02,   13.22], 'DMN_Maine_Soroa'], 
		'dongsh' : [[  116.73,   20.70], 'Dongsha_Island'], 
		'egbert' : [[  -79.75,   44.23], 'Egbert'], 
		'epa-nc' : [[  121.19,   24.97], 'EPA-NCU'], 
		'etosha' : [[   15.91,  -19.18], 'Etosha_Pan'], 
		'evoraa' : [[   -7.91,   38.57], 'Evora'], 
		'forthc' : [[   25.28,   35.33], 'FORTH_CRETE'], 
		'fortmc' : [[ -111.48,   56.75], 'Fort_McMurray'], 
		'gracio' : [[  -28.03,   39.09], 'Graciosa'], 
		'gsfccc' : [[  -76.84,   38.99], 'GSFC'], 
		'gwangj' : [[  126.84,   35.23], 'Gwangju_K-JIST'], 
		'halifa' : [[  -63.59,   44.64], 'Halifax'], 
		'hongko' : [[  114.12,   22.48], 'Hong_Kong_Sheung'], 
		'iasbss' : [[   48.57,   36.66], 'IASBS'], 
		'icipe-' : [[   34.20,   -0.42], 'ICIPE-Mbita'], 
		'iercin' : [[   -5.93,   13.28], 'IER_Cinzana'], 
		'ilorin' : [[    4.34,    8.32], 'Ilorin'], 
		'ims-me' : [[   34.26,   36.56], 'IMS-METU-ERDEMLI'], 
		'irkuts' : [[  103.09,   51.80], 'Irkutsk'], 
		'issyk-' : [[   76.98,   42.62], 'Issyk-Kul'], 
		'izanaa' : [[  -16.50,   28.31], 'Izana'], 
		'jabiru' : [[  132.89,  -12.66], 'Jabiru'], 
		'jipara' : [[  -62.85,  -10.93], 'Ji_Parana_SE'], 
		'kanger' : [[  -50.62,   67.00], 'Kangerlussuaq'], 
		'karach' : [[   67.03,   24.87], 'Karachi'], 
		'kathma' : [[   85.54,   27.60], 'Kathmandu_Univ'], 
		'keybis' : [[  -80.16,   25.73], 'Key_Biscayne2'], 
		'kuwait' : [[   47.97,   29.32], 'Kuwait_University'], 
		'lahore' : [[   74.32,   31.54], 'Lahore'], 
		'lakear' : [[  128.75,  -16.11], 'Lake_Argyle'], 
		'laparg' : [[  -67.05,   17.97], 'La_Parguera'], 
		'lecceu' : [[   18.11,   40.34], 'Lecce_University'], 
		'lucind' : [[  146.39,  -18.52], 'Lucinda'], 
		'malaga' : [[   -4.48,   36.72], 'Malaga'], 
		'manila' : [[  121.08,   14.64], 'Manila_Observatory'], 
		'maunal' : [[ -155.58,   19.54], 'Mauna_Loa'], 
		'merred' : [[  118.00,  -31.50], 'Merredin'], 
		'mexico' : [[  -99.18,   19.33], 'Mexico_City'], 
		'milyer' : [[  113.93,  -22.03], 'Milyering'], 
		'minskk' : [[   27.60,   53.92], 'Minsk'], 
		'moldov' : [[   28.82,   47.00], 'Moldova'], 
		'monter' : [[ -121.85,   36.59], 'Monterey'], 
		'moscow' : [[   37.51,   55.70], 'Moscow_MSU_MO'], 
		'munich' : [[   11.57,   48.15], 'Munich_University'], 
		'mussaf' : [[   54.47,   24.37], 'Mussafa'], 
		'mvcooo' : [[  -70.55,   41.30], 'MVCO'], 
		'nainit' : [[   79.46,   29.36], 'Nainital'], 
		'nauruu' : [[  166.92,   -0.52], 'Nauru'], 
		'nyalsu' : [[   11.86,   78.93], 'Ny_Alesund'], 
		'osakaa' : [[  135.59,   34.65], 'Osaka'], 
		'panama' : [[  -79.00,    9.00], 'Panama_BCI'], 
		'pariss' : [[    2.33,   48.87], 'Paris'], 
		'petrol' : [[  -40.50,   -9.38], 'Petrolina_SONDA'], 
		'puneee' : [[   73.81,   18.54], 'Pune'], 
		'ragged' : [[  -59.43,   13.17], 'Ragged_Point'], 
		'reunio' : [[   55.48,  -20.88], 'REUNION_ST_DENIS'], 
		'railro' : [[ -115.96,   38.50], 'Railroad_Valley'], 
		'rimroc' : [[ -116.99,   46.49], 'Rimrock'], 
		'riobra' : [[  -67.87,   -9.96], 'Rio_Branco'], 
		'saadaa' : [[   -8.16,   31.63], 'Saada'], 
		'saopau' : [[  -46.73,  -23.56], 'Sao_Paulo'], 
		'saturn' : [[ -123.13,   48.78], 'Saturn_Island'], 
		'sedebo' : [[   34.78,   30.86], 'SEDE_BOKER'], 
		'sevast' : [[   33.52,   44.62], 'Sevastopol'], 
		'silpak' : [[  100.04,   13.82], 'Silpakorn_Univ'], 
		'singap' : [[  103.78,    1.30], 'Singapore'], 
		'siouxf' : [[  -96.63,   43.74], 'Sioux_Falls'], 
		'skukuz' : [[   31.59,  -24.99], 'Skukuza'], 
		'solarv' : [[   46.40,   24.91], 'Solar_Village'], 
		'songkh' : [[  100.60,    7.18], 'Songkhla_Met_Sta'], 
		'tablem' : [[ -117.68,   34.38], 'TABLE_MOUNTAIN_CA'], 
		'tahiti' : [[ -149.61,  -17.58], 'Tahiti'], 
		'thessa' : [[   22.96,   40.63], 'Thessaloniki'], 
		'thomps' : [[  -70.95,   43.11], 'Thompson_Farm'], 
		'ubonra' : [[  104.87,   15.25], 'Ubon_Ratchathani'], 
		'univof' : [[  -95.34,   29.72], 'Univ_of_Houston'], 
		'venise' : [[   12.51,   45.31], 'Venise'], 
		'whites' : [[ -106.34,   32.63], 'White_Sands_HELSTF'], 
		'wytham' : [[   -1.33,   51.77], 'Wytham_Woods'], 
		'xiangh' : [[  116.96,   39.75], 'XiangHe'], 
		'yakuts' : [[  129.37,   61.66], 'Yakutsk'], 
		'yekate' : [[   59.55,   57.04], 'Yekaterinburg'], }	
	if code==None:
		return sites
	else:
		return sites[code]

def thresh_bins( bin=None, **kwargs ):
	'''
	Used By:
		libnva.generate_period_components() to get x value for plot 
		aeronet_stat_comps() to bin aerosol retrievals/forecasts
	'''
	thresholds      = {     'no-thresh'     : [ -9999., 9999.],
                                'extreme'       : [     1., 9999.],
                                'high'        	: [     .6,    1.],
                                'medium'        : [     .3,    .6],
                                'low'           : [     0.,   0.3],
                                'b0'            : [     0.,   .02],
                                'b1'            : [    .02,   .04],
                                'b2'            : [    .04,   .08],
                                'b3'            : [    .08,   .16],
                                'b4'            : [    .16,   .32],
                                'b5'            : [    .32,   .64],
                                'b6'            : [    .64, 9999.],
                                't6'            : [    .60, 9999.],
			
				#_placeholders, calculated in process 
				'1sig'		: [ -9999., 9999.]      }
	#_Returns all bins
	if bin == None: 
		return thresholds
	#_Returns prescribed bins
	else:	
		tmp = {}
		if type( bin ) == str:		
			tmp[bin] = thresholds[bin]
		elif hasattr( bin, '__iter__' ):
			for b in bin: tmp[b] = thresholds[b]
		return tmp

var2mode = {    'total_aod'     : 'total',
		'coarse_aod'    : 'coarse',
		'seasalt_aod'   : 'coarse',
		'dust_aod'      : 'coarse',
		'fine_aod'      : 'fine',
		'smoke_aod'     : 'fine',
		'sulfate_aod'   : 'fine', }

