CORDEXからのシミュレーションされた気候モデルデータとCRU 4.00の観測データを比較しようとしています。私はPythonでirisを実行しています。私はすべての気候モデルを稼働させることができましたが、観測されたデータはそうではありません。モデルデータはx/y軸と0.44度の解像度で回転したポールグリッドにあり、観測データは線形グリッドと0.5度の分解能にあるため、これが疑わしいです。Regridding? CRU観測されたデータとPython IrisのCORDEXデータ
それらを比較可能にするために、私はそれらを再編成する必要があると思うが、私はこれを行う方法についてちょっと混乱しており、アイリスのユーザーガイドは私をさらに混乱させている...私は比較的新しい!
これは、1つのモデル出力とCRUデータを示す折れ線グラフを作成するための単純化されたコードです:
import matplotlib.pyplot as plt
import iris
import iris.coord_categorisation as iriscc
import iris.plot as iplt
import iris.quickplot as qplt
import iris.analysis.cartography
import matplotlib.dates as mdates
def main():
#bring in all the files we need and give them a name
CCCma = '/exports/csce/datastore/geos/users/s0XXXX/Climate_Modelling/AFR_44_tas/ERAINT/1979-2012/tas_AFR-44_ECMWF-ERAINT_evaluation_r1i1p1_CCCma-CanRCM4_r2_mon_198901-200912.nc'
CRU = '/exports/csce/datastore/geos/users/s0XXXX/Climate_Modelling/Actual_Data/cru_ts4.00.1901.2015.tmp.dat.nc'
#Load exactly one cube from given file
CCCma = iris.load_cube(CCCma)
CRU = iris.load_cube(CRU, 'near-surface temperature')
#remove flat latitude and longitude and only use grid latitude and grid longitude
lats = iris.coords.DimCoord(CCCma.coord('latitude').points[:,0], \
standard_name='latitude', units='degrees')
lons = CCCma.coord('longitude').points[0]
for i in range(len(lons)):
if lons[i]>100.:
lons[i] = lons[i]-360.
lons = iris.coords.DimCoord(lons, \
standard_name='longitude', units='degrees')
CCCma.remove_coord('latitude')
CCCma.remove_coord('longitude')
CCCma.remove_coord('grid_latitude')
CCCma.remove_coord('grid_longitude')
CCCma.add_dim_coord(lats, 1)
CCCma.add_dim_coord(lons, 2)
lats = iris.coords.DimCoord(CRU.coord('latitude').points[:,0], \
standard_name='latitude', units='degrees')
lons = CRU.coord('longitude').points[0]
for i in range(len(lons)):
if lons[i]>100.:
lons[i] = lons[i]-360.
lons = iris.coords.DimCoord(lons, \
standard_name='longitude', units='degrees')
CRU.remove_coord('latitude')
CRU.remove_coord('longitude')
CRU.remove_coord('grid_latitude')
CRU.remove_coord('grid_longitude')
CRU.add_dim_coord(lats, 1)
CRU.add_dim_coord(lons, 2)
#we are only interested in the latitude and longitude relevant to Malawi
Malawi = iris.Constraint(longitude=lambda v: 32.5 <= v <= 36., \
latitude=lambda v: -17. <= v <= -9.)
CCCma = CCCma.extract(Malawi)
CRU=CRU.extract(Malawi)
#time constraignt to make all series the same
iris.FUTURE.cell_datetime_objects = True
t_constraint = iris.Constraint(time=lambda cell: 1989 <= cell.point.year <= 2008)
CCCma = CCCma.extract(t_constraint)
CRU=CRU.extract(t_constraint)
#data is in Kelvin, but we would like to show it in Celcius
CCCma.convert_units('Celsius')
#CRU.convert_units('Celsius')
#We are interested in plotting the graph with time along the x ais, so we need a mean of all the coordinates, i.e. mean temperature across whole country
iriscc.add_year(CCCma, 'time')
CCCma = CCCma.aggregated_by('year', iris.analysis.MEAN)
CCCma.coord('latitude').guess_bounds()
CCCma.coord('longitude').guess_bounds()
CCCma_grid_areas = iris.analysis.cartography.area_weights(CCCma)
CCCma_mean = CCCma.collapsed(['latitude', 'longitude'],
iris.analysis.MEAN,
weights=CCCma_grid_areas)
iriscc.add_year(CRU, 'time')
CRU = CRU.aggregated_by('year', iris.analysis.MEAN)
CRU.coord('latitude').guess_bounds()
CRU.coord('longitude').guess_bounds()
CRU_grid_areas = iris.analysis.cartography.area_weights(CRU)
CRU_mean = CRU.collapsed(['latitude', 'longitude'],
iris.analysis.MEAN,
weights=CRU_grid_areas)
#set major plot indicators for x-axis
plt.gca().xaxis.set_major_locator(mdates.YearLocator(5))
#assign the line colours
qplt.plot(CCCma_mean, label='CanRCM4_ERAINT', lw=1.5, color='blue')
qplt.plot(CRU_mean, label='Observed', lw=1.5, color='black')
#create a legend and set its location to under the graph
plt.legend(loc="upper center", bbox_to_anchor=(0.5,-0.05), fancybox=True, shadow=True, ncol=2)
#create a title
plt.title('Mean Near Surface Temperature for Malawi 1989-2008', fontsize=11)
#add grid lines
plt.grid()
#show the graph in the console
iplt.show()
if __name__ == '__main__':
main()
そして、これは私が取得エラーです:
runfile('/exports/csce/datastore/geos/users/s0XXXX/Climate_Modelling/Python Code and Output Images/Line_Graph_Annual_Tas_Play.py', wdir='/exports/csce/datastore/geos/users/s0XXXX/Climate_Modelling/Python Code and Output Images')
Traceback (most recent call last):
File "<ipython-input-8-2976c65ebce5>", line 1, in <module>
runfile('/exports/csce/datastore/geos/users/s0XXXX/Climate_Modelling/Python Code and Output Images/Line_Graph_Annual_Tas_Play.py', wdir='/exports/csce/datastore/geos/users/s0XXXX/Climate_Modelling/Python Code and Output Images')
File "/usr/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "/usr/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 78, in execfile
builtins.execfile(filename, *where)
File "/exports/csce/datastore/geos/users/s0XXXX/Climate_Modelling/Python Code and Output Images/Line_Graph_Annual_Tas_Play.py", line 124, in <module>
main()
File "/exports/csce/datastore/geos/users/s0XXXX/Climate_Modelling/Python Code and Output Images/Line_Graph_Annual_Tas_Play.py", line 42, in main
lats = iris.coords.DimCoord(CRU.coord('latitude').points[:,0], \
IndexError: too many indices
ありがとうございました!