#print j date=j for k in timestr: time=k try: f_in1=cdm.open("".join([model_output_location,model_prefix,'.cam.h1.',year,'-',mo_date,'-',date,'-',time,'.nc'])) except: print ''.join(['Tried for',mo_date,'-',date,'-',time,': moving on']) continue T=f_in1('T') p0=f_in1('P0') a=f_in1('hyam') b=f_in1('hybm') ps=f_in1('PS') Z3=f_in1('Z3') P=create_variables.create_P(ps,a,b,p0) BLH,dThetadZ=create_variables.BLH(P,T,Z3) outfile=''.join([derived_output_location,'BLH_',model_prefix,'.cam.h1.',year,'-',mo_date,'-',date,'-',time,'.nc']) f_out=cdm.open(outfile,'w') f_out.write(BLH) f_out.write(dThetadZ) f_out=create_netcdfs.transfer_attributes(f_in1,f_out) f_out=create_netcdfs.globalAttWrite(f_out) ; # Use function to write standard global atts to output file setattr(f_out,'script_URL','https://github.com/crterai/Analysis/commit/') filename=os.path.basename(__file__) setattr(f_out,'script_used',filename) #f_out=create_netcdfs.add_git_hash(f_out) f_in1.close() f_out.close()
continue U=f_in1('U',time=slice(0,1)) V=f_in1('V',time=slice(0,1)) #p0=f_in1('P0') #a=f_in1('hyam') #b=f_in1('hybm') #ps=f_in1('PS',time=slice(0,1)) #P=create_variables.create_P(ps,a,b,p0) #q700=create_variables.Variable_hPa(Q,P,700) var1=U var2=V var1id=var1.id var2id=var2.id var1_regrid=var1.regrid(gpcp_grid,regridTool='esmf',regridMethod='bilinear') var2_regrid=var2.regrid(gpcp_grid,regridTool='esmf',regridMethod='bilinear') var1_regrid=create_netcdfs.transfer_attributes(var1,var1_regrid) var2_regrid=create_netcdfs.transfer_attributes(var2,var2_regrid) var1_regrid.notes="".join(["Regridded data to 1degx1deg with regrid_variables.py",var1_regrid.notes]) var2_regrid.notes="".join(["Regridded data to 1degx1deg with regrid_variables.py",var2_regrid.notes]) var1_regrid.id=var1id var2_regrid.id=var2id outfile=''.join([derived_output_location,'regridded_',model_prefix,'.cam.h1.',year,'-',mo_date,'-',date,'-',time,'.nc']) f_out=cdm.open(outfile,'w') f_out.write(var1_regrid) f_out.write(var2_regrid) f_out=create_netcdfs.transfer_attributes(f_in1,f_out) f_out=create_netcdfs.globalAttWrite(f_out) ; # Use function to write standard global atts to output file setattr(f_out,'script_URL','https://github.com/crterai/LagrangianAnalysis/commit/') filename=os.path.basename(__file__) setattr(f_out,'script_used',filename)