# Lixu, 09/10/2021 # Raw script is from Jeff Pierce # This scirpt is used to create emission-flux weighted injections at corresponding GEOS-Chem resolution. # The emission-flux weighted injections will help us tackle the issue the pixels without emissions would reduce the heights, if they are just simply averaged into a coarse grid. from pylab import * from netCDF4 import Dataset import datetime # grid setting #grid='4x5' #grid='2x2.5' #grid='0.5x0.667' #grid='0.5x0.625_NA' grid='0.25x0.3125_NA' #### Processing data from GC-ready data # Directory setting direc_input='/home/lj152920/project/geos-chem/ExtData/HEMCO/GFAS/v2018-09/2021/' direc_output='/home/lj152920/project/geos-chem/ExtData/HEMCO/GFAS/v2021-09/2021/' # Date setting #yrmo=['201807','201808','201809','201810','201811','201812'] #yrmo=['201907','201908','201909'] #yrmo=['201808'] #yrmo=['202001','202002','202003'] #yrmo=['202001','202002','202003','202004','202005','202006','202007','202008','202009','202010','202011','202012'] #yrmo=['201801','201802','201803','201804','201805','201806','201807','201808','201809','201810','201811','201812'] #yrmo=['201901','201902','201903','201904', # '201905','201906','201907','201908', # '201909','201910','201911','201912'] yrmo=['202101','202102','202103','202104','202105','202106','202107','202108','202109','202110','202111','202112'] if grid == '4x5': late=empty((47)) lone=empty((73)) late[0]=-90. late[-1]=90. late[1:-1]=arange(-88.,90.,4.) lone[0]=0. lone[-1]=360. lone[1:-1]=arange(5.,360.,5.) switch_lon = False elif grid == '0.5x0.667': # maybe has alignment issue late=empty((361)) lone=empty((541)) late[0]=-90. late[-1]=90. late[1:-1]=arange(-89.5,90.,0.5) lone[0]=0. lone[-1]=360. lone[1:-1]=arange(2./3.,360.,2./3.) switch_lon = False elif grid == '2x2.5': late=empty((92)) lone=empty((145)) late[0]=-90. late[-1]=90. late[1:-1]=arange(-89.,90.,2.) lone[0]=0. lone[-1]=360. lone[1:-1]=arange(2.5,360.,2.5) switch_lon = False elif grid == '0.5x0.625_NA': late=empty((122)) lone=empty((162)) late[0]=9.75 late[-1]=70.25 late[1:-1]=arange(10.25,70.,0.5) lone[0]=219.6875 lone[-1]=320.3125 lone[1:-1]=arange(219.6875+0.625,320.,0.625) switch_lon = True elif grid == '0.25x0.3125_NA': late=empty((203)) lone=empty((226)) late[0]=9.75-0.25/2. late[-1]=60.+0.25/2. late[1:-1]=arange(9.75+0.25/2,60.,0.25) lone[0]=360.-130.-0.3125/2. lone[-1]=360.-60.+0.3125/2. lone[1:-1]=arange(360.-130.+0.3125/2.,360.-60.,0.3125) switch_lon = True latc=(late[0:-1]+late[1:])/2. lonc=(lone[0:-1]+lone[1:])/2. for yr in yrmo: fname=direc_input + 'GFAS_' + yr + '.nc' fid=Dataset(fname,'r') lata=fid.variables['lat'] lat=lata[:] lona=fid.variables['lon'] lon=lona[:] timea=fid.variables['time'] time=timea[:] nt = len(time) mamia=fid.variables['mami'] mami=mamia[:] ocfirea=fid.variables['ocfire'] ocfire=ocfirea[:] mami_avg=empty((nt,len(latc),len(lonc))) mami_avg_weight=empty((nt,len(latc),len(lonc))) ocfire_avg=empty((nt,len(latc),len(lonc))) for y in range(0,len(latc)): print(y) for x in range(0,len(lonc)): islat=where(lat[:]>late[y])[0][0] inlat=where(lat[:]lone[x])[0][0] ielon=where(lon[:]