如何利用 Ferret 來讀寫資料?


  • 資料格式簡介:

    1. ASCII
    2. Binary
    3. NetCDF (.nc / .cdf)
  • 使用 Ferret 來讀寫 ASCII 檔案

    (指令:讀取資料用file;寫入資料用list)

    1. 定義格點

      • 直接定義

        define axis/x[y,z or t]=start:end:interval x[y,z or t]_axis_name
        define grid/x=x_axis_name/y=y_axis_name/z=z_axis_name/t=t_axis_name grid_name

        EX1:
        define axis/x=1:20:1 xx
        define axis/y=1:15:1 yy
        define grid/x=xx/y=yy gg
        EX2:
        define axis/x=101E:120E:1 xx
        define axis/y=1N:15N:1 yy
        define grid/x=xx/y=yy gg

      • 由檔案定義

        file/var=axis_var_name/col=columns#/format=(data_format) file_name
        define axis/x/from/name=x_axis_name/unit=lon[lat, meter or time_unit] axis_var_name

        EX:
        file/var=lon_e/col=1/format=(f8.4) lon_e.dat
        define axis/x/from/name=xx/unit=lon lon_e
        file/var=lat_e/col=1/format=(f8.4) lat_e.dat
        define axis/y/from/name=yy/unit=lat lat_e
        define grid/x=xx/y=yy gg

    2. 開啟檔案

      file/var=axis_var_name/format=(fortran_format)/col=columns#/grid=grid_name file_name

      EX:
      file/var=topo/format=(20f10.4)/col=20/grid=gg topo.dat

    3. 寫入檔案
      list/clobber[append][/nohead]/format=(fortran_format)/order=xyzt/file=file_name var_name
      EX:
      list/clobber/nohead/format=(20f10.3)/order=xy/file=topo2.dat topo
  • 使用 Ferret 來讀寫 NetCDF 檔案

    (指令:讀取資料用use;寫入資料用save)

    1. 讀取資料(不需定義格點)

      use file_name

      EX:
      use topo

    2. 寫入資料

      save/clobber[append]/file=file_name var_name

      EX1:
      save/clobber[append]/file=topo.cdf topo
      EX2:
      save/clobber[append]/file=topo.nc topo

results matching ""

    No results matching ""