zhanghouxing的个人博客分享 http://blog.sciencenet.cn/u/zhanghouxing

博文

Micromet 降雨插值(II)

已有 5251 次阅读 2016-6-28 22:06 |系统分类:科研笔记| 降雨, 插值, micromet

关于Micromet降雨插值的基础,请参考另一篇博文:micromet的一点总结 (I)

1. 准备已有气象站点的数据,先保存到excl, 然后另存为.dat文件,然后用makeinput的fortran代码处理成micromet需要的格式。数据的格式见:

SnowModel/MicroMet met data 输入格式要:
******************************************************************************************************
1)输入数据需要安装下面的格式(一个文件对应一个站点)

year   mo   dy    hr     stn_id  easting  northing  elevation   Tair     RH     speed    dir     precip
(yyyy) (mm) (dd) (hh.hh) (number)   (m)       (m)      (m)        (C)    (%)     (m/s)   (deg)    (mm/dt)

2002   10    1   12.00    101   426340.0  4411238.0  3598.0     0.92    57.77     4.80   238.29 -9999.00
2002   10    2   12.00    101   426340.0  4411238.0  3598.0    -3.02    78.77 -9999.00 -9999.00 -9999.00
2002   10    8   12.00    101   426340.0  4411238.0  3598.0    -5.02    88.77 -9999.00 -9999.00 -9999.00
...
这是一个以日为步长的例子。对于小时步长数据,你只需要把小时的数据列出来即可。

这些数据以ascii格式存储,一种做法,就是把他们咋excel中组织起来,然后保存为.csv格式comma delimited)的即可

我有个程序可以把所有单独的站点统一起来,并且将其转化Micromet  met station输入文件。

2) 站点的ID必须是数字,不能是字符,但是你可以选择任何你想要的编号。

3) 任何缺失的数据或者你定义的无效数据都需要 -9999.0来替换,像上面那样。

4) 对于任何站点给出相应的缺失数据日期是相当好的。我的意思是如果你在给定的某一天没有数据,
    你不需要把那一天或那一行的缺失数据都列出来(如上面所示)。但是要注意的是列出所有的缺失值也是可以的,这个情况下
    日期 id 坐标 高程。

5)你至少需要一个站点的观测数据,模型开始运行时,会对这点进行检查。

6)如果你要运行Micromet 预处理模块,数据的格式必须是:

    year   mo   dy    hr       Tair     RH      speed    dir     precip
(yyyy) (mm) (dd) (hh.hh)     (C)     (%)     (m/s)   (deg)    (mm/dt)

2002   11   24   12.00    -6.33    96.72    18.17   282.27     0.04
2002   11   25   12.00    -6.46    98.35    20.90   281.22 -9999.00
2002   11   26   12.00    -6.51    98.33    19.46   282.40     0.23

 那么,id 坐标及高程将被嵌入作为预处理模块运行的一部分。

7)经纬度不一定要是UTM投影的。他们只是需要再投影的坐标系统表示,而且这个投影系统必须要和地形和植被数据
 投影系统一样。因此比如你定义植被和地形数据的左下角坐标是(0.0),那么站点坐标必须以这个定义的坐标系统
 为基础。
*********************************************************************************************************  

2. 地形数据和植被数据的准备 (参考docs文件夹文档)
*********************************************************************************************************
1)SnowModel/MicroMet需要2种格网数据,dem和植被分布数据。这个矩阵必须在各个方面的都相同。

2)他们可以以ascii的格式保存,也可以以2进制保存。
  对于ascii格式:
  a) 必须有6行头文件(他们是什么不重要,什么都不是;因为这些值来自于snowmdodel.par 模型设置文件中)
  b) 这些行必须从西北角开始从左到右写。然后一行一行写下去。
  d) 下面是Fortran写的例子:
     open (23,file='topo.dat')
     write (23,*) 'ncols             101'
     write (23,*) 'nrows             101'
     write (23,*) 'xllcorner           0'
     write (23,*) 'yllcorner           0'
     write (23,*) 'cellsize           30'
     write (23,*) 'NODATA_value  -9999.0'
     do j=ny,1,-1
       write (23,90) (topo(i,j),i=1,nx)
     enddo
     90  format (101f12.4)
3)模型矩阵空间(从左到右,从下到上写)和GIS数据格式的y轴是相反,但是我为了将输出改写成GIS格式,因此我在输出的时候:
   do j=ny,1,-1
       write (23,form) (swe_depth(i,j),i=1,nx)
     enddo
   所有是这样结果:在模型中,任何二进制的输入和输出都是按照大气模型的约定,也就是从左到右,从下到上写;
                   任何ascii格式的输入和输出都是按照GIS的约定。
模型空间:
1 2 3
4 5 6
7 8 9

gis 空间
7 8 9
4 5 6
1 2 3
存储时   第1列              第2列                         。。。       第j列        。。。  第88 列
第1行    name [0][0] ,   name [0][1]  name [0][2]。。。, name [0][j-1] 。。。 ,name [0][87]
第2行    name [0][0] ,   name [0][1]  name [0][2]。。。,name [0][j-1] 。。。 ,name [0][87]  
。。。
第i行     name [i-1][0] , name [i-1][1], name [i-1][2]。。。,name [i-1][j-1] 。。。,name [i-1][87]  
。。。
第12行  name [11][0] ,  name [0][1],  name [0][2] 。。。, name [11][j-1]。。。, name [11][87]
无论Fortran还是C,C++的,二维数组前面一个是行,后面一个是列。
Fortran:填满一列的每一行,再换列填下一列的每一行
C:填满一行的每一列,在换行填下一行的每一列 4)栅格数据包括缺失数据和有效数据2类。

5)栅格的坐标信息定义在 snowmodel.par 文件中。包括:
  ! 栅格行列数
    nx =31
    ny= 31
  !deltax=栅格横向增量.  m
  !deltax=栅格纵向增量.  m
     deltax = 200.0
     deltay = 200.0
  !栅格左下角位置坐标值(m)
  !xmn= x坐标
  !ymn= y坐标
     xmn = 426192.
     ymn = 407812.
6)你用的什么地形和植被文件,文件名称及位置也定义在 snowmodel,par文件中。包括:
  !定义地形和植被文件的保存格式  (ascii = 1.0, GrADS = 0.0).
     ascii_topoveg = 0.0
  !如果用GrADS文件,也不能把ascii文件注释掉,相反亦然。
    GrADS:
    topoveg_fname = xxxxxx
     topoveg_fname = ~/clpx/topoveg/200m_data/fraser.topoveg.200m.gdat
    ascii:  
    topo_ascii_fname = xxxxxx
    veg_ascii_fname = xxxxxx
    topo_ascii_fname = topoveg/topo_ascii_100m.dat
    veg_ascii_fname = topoveg/veg_ascii_100m.dat

7)地形数据的值是m

8) 下面是在植被编码,意味着可以是1到30:
  code description           veg_shc  example                    class
!
!  1  coniferous forest       15.00  spruce-fir/taiga/lodgepole  forest
!  2  deciduous forest        12.00  aspen forest                forest
!  3  mixed forest            14.00  aspen/spruce-fir/low taiga  forest
!  4  scattered short-conifer  8.00  pinyon-juniper              forest
!  5  clearcut conifer         4.00  stumps and regenerating     forest
!
!  6  mesic upland shrub       0.50  deeper soils, less rocky    shrub
!  7  xeric upland shrub       0.25  rocky, windblown soils      shrub
!  8  playa shrubland          1.00  greasewood, saltbush        shrub
!  9  shrub wetland/riparian   1.75  willow along streams        shrub
! 10  erect shrub tundra       0.65  arctic shrubland            shrub
! 11  low shrub tundra         0.30  low to medium arctic shrubs shrub
!
! 12  grassland rangeland      0.15  graminoids and forbs        grass
! 13  subalpine meadow         0.25  meadows below treeline      grass
! 14  tundra (non-tussock)     0.15  alpine, high arctic         grass
! 15  tundra (tussock)         0.20  graminoid and dwarf shrubs  grass
! 16  prostrate shrub tundra   0.10  graminoid dominated         grass
! 17  arctic gram. wetland     0.20  grassy wetlands, wet tundra grass
!
! 18  bare                     0.01                              bare
!
! 19  water/possibly frozen    0.01                              water
! 20  permanent snow/glacier   0.01                              water
!
! 21  residential/urban        0.01                              human
! 22  tall crops               0.40  e.g., corn stubble          human
! 23  short crops              0.25  e.g., wheat stubble         human
!
! 24  user defined (see below)
! 25  user defined (see below)
! 26  user defined (see below)
! 27  user defined (see below)
! 28  user defined (see below)
! 29  user defined (see below)
! 30  user defined (see below)

9)如果没有植被数据,仍然可以运行模型,你只需要在文件snowmodel.par中将vegetation设置为常数即可。
  定义为0表示用植被分布数据,大于1或等于1表示对应的植被均匀分布,
   const_veg_flag = 12.0
   const_veg_flag = 0.0
*********************************************************************************************************
 
3. 配置模型参数    
*********************************************************************************************************
! Number of x and y cells in the computational grid.
!Ling Zhang: nx 为列数,ny为行数
     nx = 50
     ny = 35

! deltax = grid increment in x direction.  Meters.
! deltay = grid increment in y direction.  Meters.
!Ling Zhang: 格网大小
     deltax = 5000.0
     deltay = 5000.0

! Location (like UTM, in meters) value of lower-left grid point.
!   xmn = value of x coordinate in center of lower left grid cell.
!     Meters.
!   ymn = value of y coordinate in center of lower left grid cell.
!     Meters.
     xmn =   -571811.53424883
     ymn = 4043727.467686

! Model time step, dt.  Should be the same increment as in the input
!   data file.  In seconds.
!Ling Zhang: 时间步长
!   One day.
    dt = 86400.0
!   Six hours.
!     dt = 21600.0
!   Three hours.
!     dt = 10800.0
!   One hour.
!      dt = 3600.0

! Start year of input data file.  Four digit year.  Integer.
!Ling Zhang: 开始时间
     iyear_init = 1989

! Start month of input data file.  One or two digit month.  Integer.
     imonth_init = 1

! Start day of input data file.  One or two digit day.  Integer.
     iday_init = 1

! Start hour of input data file.  Local time, like in solar time.
!   Decimal hour.  Each day the clock runs from 0.00 through 23.99.
!   Real.
     xhour_init = 12.0

! Number of model iterations defines how many times to process.
!Ling Zhang: 时间总长度,本例为总共的天数
!      max_iter = 7656
      max_iter = 7670
! Define the meteorologial input file name.  Note that this input
!   file has very specific input format requirements (see the
!   MicroMet preprocessor).  The required met variables are:
!   Tair (deg C or K), rh (%), wind speed (m/s), wind direction
!   (0-360 True N), and precipitation (mm/time_step).
!      met_input_fname = met/SnowModel_test_met.dat
     met_input_fname = met/ghq_met.dat

! The number used as an undefined value for both inputs and outputs.
     undef = -9999.0

! Define whether the topography and vegetation input files will
!   be ARC/INFO ascii text (grid) files, or a GrADS binary file
!  (ascii = 1.0, GrADS = 0.0).
     ascii_topoveg = 1.0

! Define the GrADS topography and vegetation input file name
!   (record 1 = topo, record 2 = veg).  Note that if you are using
!     ascii files, you still cannot comment this line out (it is okay
!     for it to point to something that doesn't exist) or you will
!     an error message.
     topoveg_fname = xxxxxx

! For the case of using ascii text topography and vegetation files,
!   provide the file names.  Note that if you are using a grads
!     file, you still cannot comment these two lines out (it is okay
!     for it to point to something that doesn't exist) or you will
!     an error message.
!     topo_ascii_fname = xxxxxx
!     veg_ascii_fname = xxxxxx
     topo_ascii_fname = topo_veg/hhup_dem.asc
     veg_ascii_fname = topo_veg/fake_veg.asc
**********************************************************************
对DEM进行重采样,为5Km
裁剪得到一个50×30的矩阵
**********************************************************************
     
! Define which fields you want to process/distribute. 1 = do it,
!   0 = don't do it.  As an example, if you are running SnowTran-3D
!   with no melting, you don't need solar radiation.
!Ling Zhang 定义插值的变量
     i_tair_flag = 0
     i_rh_flag = 0
     i_wind_flag = 0
     i_solar_flag = 0
     i_longwave_flag = 0
     i_prec_flag = 1
     
! Define whether the precipitation adjustment factor, with units of
!   km^-1 (kind of a precipitation lapse rate, used to adjust the
!   precipitation for locations above and below the precipitation
!   observing station(s)), is to use the default monthly lapse
!   rates (= 0) or user supplied monthly lapse rates (= 1).  To use
!   user supplied lapse rates, you have to edit the user lapse rate
!   data array in micromet_code.f (subroutine get_lapse_rates).
     iprecip_lapse_rate_user_flag = 1
     
    !Ling Zhang  修改代码:1481行
*******************************************************************
c If you want to use the 'user' array, put your monthly values in
c   here and set iprecip_lapse_rate_user_flag = 1 in the .par file.
     data precip_lapse_rate_user /0.1296,0.2108,0.109,0.1657,0.2384,
    &                              0.2641,0.272,0.2859,0.2364,0.2056,
    &                             0.0419,0.225/
********************************************************************
   
     
! The code is set up to write out an individual data file for each
!   sub-model.  Define whether you want the data written out
!   (print_micromet = 1.0, else 0.0), and the name of that output
!   file.
     print_micromet = 1.0
     micromet_output_fname = outputs/output1989-2009.gdat
*********************************************************************************************************
 
4. built 生成可执行文件,snowmodel.exe
5. 执行即可。        




https://blog.sciencenet.cn/blog-922140-987361.html

上一篇:缺失气象数据填补方法
下一篇:一种很好的C语言数据组织结构
收藏 IP: 210.72.80.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-7-18 02:35

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部