avatar

AngYi

Aim for the stars, and beyond.

  • 首页
  • 分类
  • 标签
  • 归档
  • 相册
  • 关于我
Home DINEOF插值重构
文章

DINEOF插值重构

Posted 2021-06-10 Updated 2023-10- 17
By AngYi
15~19 min read

D4h1hE

DINEOF

好多人在遥感数据重构中会用到DINEOF方法,但是很多人不会用,这里记录笔记和教程。

官网: http://modb.oce.ulg.ac.be/mediawiki/index.php/DINEOF

下载

从网站下载压缩包解压之后,有如图的目录结构,一般只需要用到框出来的这几样东西。

文件目录
将下载文件夹里需要的文件复制到工作目录下,然后进行以下操作。

读取数据

基本步骤:

  1. 读取自己的文件,整理三个东西,分别是你要插值的变量,陆地掩码值,日期;
  2. 利用下载的dineof中的Matlab函数gwrite写成dineof可以直接读的数据.dat格式
  3. 写好配置文件dineof.init用shell脚本运行dineof dineof.init
%% 南海叶绿素 元数据 写成DINEOF的格式
filename = 'CCI_ALL-v5.0-DAILY.nc';
ncinfos= ncinfo(filename);
chlor_a = ncread(filename,'chlor_a');
lon = ncread(filename,'lon');
lat = ncread(filename,'lat');

time = ncread(filename,'time');

% generate mask
[m,n,k] = size(chlor_a)
mask = ones(m,n);
for i = 1:m
    for j = 1:n
        if sum(isnan(chlor_a(i,j,:)))>k-15
            mask(i,j) = 0;
        end
    end
end

gwrite('./occi14dat/chla.dat',chlor_a);
gwrite('./occi14dat/mask.dat',mask);
gwrite('./occi14dat/date.dat',time);

配置文件

有几个点解释一下:

  • 陆地掩码:0-1矩阵,将数据中NaN,或者缺失率超过一定比例的就设置为0,需要插值的海域设置为0.
  • 时间序列:生成一个代表时间连续性的时间列,不需要日期,只需要表示时间是否连续即可。比如说是一个月的天数据,那么时间就是1-30即可。如果中间缺失某一天,那么连续值需要跳过。
  • 配置文件dineof.init:# ! 表示注释,不执行,我们需要将matlab生成的dat文件路径在配置文件中详细写明确。分别为data=[] mask=[] time=[] 还有输出放在哪个文件夹里 output=[],除此之外,还有一些详细的参数,至于这些参数就需要读者理解原理,根据具体的任务和计算资源来进行调整了。
!
! INPUT File for dineof 2.0
!
! Lines starting with a ! or # are comments
!


! gappy data to fill by DINEOF. For several matrices, separate names with commas
! Example:
!          data = ['seacoos2005.avhrr','seacoos2005.chl']

data = ['./occi14dat/chla.dat']

!data = ['2Dbelcolour_region_period_anomaly.gher']

!data = ['2Dbelcolour_region_period_dat.gher']

! land-sea mask of gappy data. Several masks separated by commas:
! Example :
!           mask = ['seacoos2005.avhrr.mask','seacoos2005.chl.mask']

mask = ['./occi14dat/mask.dat']

!mask = ['transpmaskindineof1D.gher']


time = './occi14dat/date.dat'
alpha = 0.01
numit = 3


!
! Sets the numerical variables for the computation of the required
! singular values and associated modes.
!
! Give 'nev' the maximum number of modes you want to compute

nev = 5

! Give 'neini' the minimum  number of modes you want to compute

neini = 1

! Give 'ncv' the maximal size for the Krylov subspace
! (Do not change it as soon as ncv > nev+5)
! ncv must also be smaller than the temporal size of your matrix

ncv = 10

! Give 'tol' the treshold for Lanczos convergence
! By default 1.e-8 is quite reasonable

tol = 1.0e-8

! Parameter 'nitemax' defining the maximum number of iteration allowed for the stabilisation of eofs obtained by the cycle ((eof decomposition <-> truncated reconstruction and replacement of missing data)). An automatic criteria is defined by the following parameter 'itstop' to go faster

nitemax = 300

! Parameter 'toliter' is a precision criteria defining the threshold of automatic stopping of dineof iterations, once the ratio (rms of successive missing data reconstruction)/stdv(existing data) becomes lower than 'toliter'.

toliter = 1.0e-3

! Parameter 'rec' for complete reconstruction of the matrix
! rec=1 will reconstruct all points; rec=0 only missing points

rec = 1

! Parameter 'eof' for writing the left and right modes of the
!input matrix. Disabled by default. To activate, set to 1

eof = 1

! Parameter 'norm' to activate the normalisation of the input matrix
!for multivariate case. Disabled by default. To activate, set to 1

norm = 0

! Output folder. Left and Right EOFs will be written here
!

!Output = './'
Output = 'Output14/'

!
! user chosen cross-validation points,
! remove or comment-out the following entry if the cross-validation points are to be chosen
! internally
!

! clouds = 'crossvalidation.clouds'

!
! "results" contains the filenames of the filled data
!

!results = ['All_95_1of2.sst.filled']
!results = ['Output/F2Dbelcolour_region_period_datfilled.gher']

results = ['./Output14/chla_filled.nc']

! seed to initialize the random number generator

seed = 243435


!-------------------------!
! cross-validation points !
!-------------------------!

!number_cv_points = 7000

!cloud surface size in pixels
cloud_size = 500



!cloud_mask = 'crossvalidation.mask'


!
! END OF PARAMETER FILE
!

运行DINEOF

配置好dineof.init文件之后,就可以在shell中通过如下命令来跑模型:

cd ./
./dineof dineof.init

Shell

刚开始会输出一些你的输入信息,包括输入的文件和数据大小,同时还会计算数据的缺失率,后面就是模型的迭代过程了。

运行结束后,输出文件保存在Output/文件夹下,可以用Matlab通过下载的脚本里面的gread来调用,查看dineof插值之后的数据。

%% 读取DINEOF之后的数据 
chla_filled = gread('Output/chla_filled.nc');

下载地址

好像官方不开放了,我看最近需要这个的人比较多,给大家分享云盘链接哈,大家帮忙点个赞哈哈 (只是为了填充数据库哈哈,没有流量也不会变现)

dineof-3.0
https://www.aliyundrive.com/s/CjKom7qdpPq
点击链接保存,或者复制本段内容,打开「阿里云盘」APP ,无需下载极速在线查看,视频原画倍速播放。
数据分析
matlab
License:  CC BY 4.0
Share

Further Reading

Apr 4, 2022

Matplotlib常用布局-代码仓库

Matplotlib常用布局-代码仓库行列组合# 2 行 4 列 fig,ax = plt.subplots(2,4,figsize=(12,18),dpi=250,sharey=True,sharex=False) # 第一行 第一列ax[0][0].plot(spring_result.sub_

Nov 7, 2021

CMIP6 海气耦合模型数据下载

Oct 15, 2021

数据处理与特征工程

推荐菜菜的sklearn完整版,价值4999元的最全机器学习这应该是我找到的最系统,最通俗易懂、实践性最强、教学讲解最好的网络课程,非常适用新手入门和回看复习。这里有部分课件(链接: https://pan.baidu.com/s/1AZ5h_uDKMBpxNvPIeASRBQ 提取码: osw8)

OLDER

认识你自己

NEWER

安装Nvidia套件和Tensorflow环境

Recently Updated

  • DeepSeek 创始人梁文峰采访:创新、人才与中国 AI 发展
  • 福州-厦门之行
  • 我有自己的摄影网站啦
  • 借助Ollama一键本地部署CodeGeex,让AI帮你打工
  • Dash 进阶技巧

Trending Tags

ssh linux matlab 感悟 读书 blog git python flask ML

Contents

©2025 AngYi. Some rights reserved.

Using the Halo theme Chirpy