= Visualization and animating of Pan European Climate Simulation with the WRF Model using ParaView Python-Scripting = == Data == In this example, one data file containing 12 timesteps was given. The file is stored at /arch/software/grafprod/data/slts.fz-juelich.de/k.goergen/WRF_initial_example/wrf_rv025_r07_test.wrfout_3km.20100702130000-20100703000000.nc in netCDF format. As netCDF 3 is used, the file had to be converted to netCDF 4 (which is hdf5) via "nccopy -k 4 foo3.nc foo4c.h5". == Variables of Interest == === 3D Scalar Variables === The 3D variables are located on a grid of size 49x1552x1600. As for each variable all 12 timesteps are stored in one hdf5 array, the size of this array is 12x49x1552x1600, obviously.\\ Here is a list of interesting scalar variables: * CLDFRA: Cloud Fraction (values from 0 to 1) * QNICE: Ice Number concentration (values from -1.1e-8 to 1.3e6, good value for visualisation: 10000) * QNRAIN: Rain Number concentration (values from -3e-5 to 620000, good value for visualisation: 5000) * QVAPOR: Water vapor mixing ratio (values from -0.0043 bis 0.0207, good value for visualisation: 0.005) === 3D Vector Variables === The wind components are stored on a staggered grid. Please note, that therefore the array size of those components vary along one axis each.\\ Vector Components: * U: x-wind component (12 x 49 x 1552 x 1601) * V: y-wind component (12 x 49 x 1553 x 1600) * w: z-wind component (12 x 50 x 1552 x 1600) === 2D Scalar Variables === There are also a couple of surface related 2D variables includes in the data, located on a grid of size 12x1552x1600.\\ Some examples: * HGT: Terrain Height * LH: Latent Heat Flux at the Surface * LANDMASK * LU_INDEX * QFX * SNOWH * SST * T2 * TMN * VEGFRA == Coordinates == The coordinates of the 3D grid are given by lon, lat and two pressure values: * XLON: 12 x 1552 x 1600 * XLAT: 12 x 1552 x 1600 * PH: 12 x 50 x 1552 x 1600 * PHB: 12 x 50 x 1552 x 1600 As !ParaView can not load the coordinates of the grid from the original data, a new data file coordinates.h5 is generated by the Python script generate_coordinates.py. In this script, the longitude values are corrected by the cosine of the latitude values: {{{ #!python xlat = np.cos(xlat/180.0*np.pi) print "generating longitude" dsetIn = fIn['/XLONG'] dsetOut = fOut.create_dataset("/XLONG", (num_x, num_y, num_z), dtype=np.float32) xlon = dsetIn[0, : , :] mi = np.min(xlon) ma = np.max(xlon) xlon = (xlon-(ma+mi)/2.0) * xlat }}} Also the height value is calculated as PH+PHB. As these pressure values are located on a staggered grid, two grid levels must be averaged: {{{ #!python dsetIn1 = fIn['/PH'] dsetIn2 = fIn['/PHB'] dsetOut = fOut.create_dataset("/Z", (num_x, num_y, num_z), dtype=np.float32) ph1 = dsetIn1[0, 0, : , :] phb1 = dsetIn2[0, 0, : , :] for z in range(num_x): sys.stdout.write("%d " % (z)) ph2 = dsetIn1[0, z+1, : , :] phb2 = dsetIn2[0, z+1, : , :] result = (ph1+phb1+ph2+phb2)*0.00025/(9.81*2) dsetOut[z, : , :] = result print "min=%f, max=%f" % (np.min(result), np.max(result)) ph1 = ph2 phb1 = phb2 }}} == Time Information == The time value of the 12 timesteps is store in the variable XTIME, which is just a one-dimensional array of size 12.