-
Notifications
You must be signed in to change notification settings - Fork 4
/
himawari_headerinfo.f90
268 lines (240 loc) · 8.75 KB
/
himawari_headerinfo.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
!******************************************************************************%
! *
! * Copyright (C) 2016-2021 Simon Proud <[email protected]>
! * License: CC BY-NC-ND 4.0
! *
! ******************************************************************************/
!*******************************************************************************
! This stores all the information that can be read from the HSD header struct
!*******************************************************************************
module himawari_headerinfo
use himawari
use iso_c_binding
implicit none
private
public :: himawari_t_Basic_Info, &
himawari_t_Data_Info, &
himawari_t_Proj_Info, &
himawari_t_Navi_Info, &
himawari_t_Calib_Info, &
himawari_t_IR_Calib_Info, &
himawari_t_VIS_Calib_Info, &
himawari_t_InterCalib_Info, &
himawari_t_Segm_Info, &
himawari_t_NaviCorr_Info, &
himawari_t_ObsTime_Info, &
himawari_t_Error_Info, &
himawari_t_Spare, &
himawari_t_Correct_Table, &
himawari_t_IR_Header, &
himawari_t_VIS_Header
! Basic info regarding the file and processing
type :: himawari_t_Basic_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
integer(kind=ahi_sint) :: header_Num
integer(kind=ahi_byte) :: byteOrder
character*16 :: satName
character*16 :: proName
character*4 :: ObsArea
character*2 :: ObsInfo
integer(kind=ahi_sint) :: TimeLine
real(kind=ahi_dreal) :: ObsStartTime
real(kind=ahi_dreal) :: ObsEndTime
real(kind=ahi_dreal) :: fileCreationMjd
integer(kind=ahi_lint) :: totalHeaderLen
integer(kind=ahi_lint) :: dataLen
integer(kind=ahi_byte) :: qflag1
integer(kind=ahi_byte) :: qflag2
integer(kind=ahi_byte) :: qflag3
integer(kind=ahi_byte) :: qflag4
character*32 :: verName
character*128 :: fileName
character*40 :: spare
end type himawari_t_Basic_Info
! Some more basic info, mostly unused by us
type :: himawari_t_Data_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
integer(kind=ahi_sint) :: bitPix
integer(kind=ahi_sint) :: nPix
integer(kind=ahi_sint) :: nLin
integer(kind=ahi_byte) :: comp
character*40 :: spare
end type himawari_t_Data_Info
! Projection info, very useful for geoprocessing
type :: himawari_t_Proj_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
real(kind=ahi_dreal) :: subLon
integer(kind=ahi_lint) :: cfac
integer(kind=ahi_lint) :: lfac
real(kind=ahi_sreal) :: coff
real(kind=ahi_sreal) :: loff
real(kind=ahi_dreal) :: satDis
real(kind=ahi_dreal) :: eqtrRadius
real(kind=ahi_dreal) :: polrRadius
real(kind=ahi_dreal) :: projParam1
real(kind=ahi_dreal) :: projParam2
real(kind=ahi_dreal) :: projParam3
real(kind=ahi_dreal) :: projParamSd
integer(kind=ahi_sint) :: resampleKind
integer(kind=ahi_sint) :: resampleSize
character*40 :: spare
end type himawari_t_Proj_Info
! Could also be used for geoproc, but we don't bother.
! Most of this is unnecessary when using the previous.
type :: himawari_t_Navi_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
real(kind=ahi_dreal) :: navMjd
real(kind=ahi_dreal) :: sspLon
real(kind=ahi_dreal) :: sspLat
real(kind=ahi_dreal) :: satDis
real(kind=ahi_dreal) :: nadirLon
real(kind=ahi_dreal) :: nadirLat
real(kind=ahi_dreal) :: sunPos_x
real(kind=ahi_dreal) :: sunPos_y
real(kind=ahi_dreal) :: sunPos_z
real(kind=ahi_dreal) :: moonPos_x
real(kind=ahi_dreal) :: moonPos_y
real(kind=ahi_dreal) :: moonPos_z
character*40 :: spare
end type himawari_t_Navi_Info
! Main calibration structure for each band
type :: himawari_t_Calib_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
integer(kind=ahi_sint) :: bandNo
real(kind=ahi_dreal) :: CenWaveLen
integer(kind=ahi_sint) :: bitPix
integer(kind=ahi_sint) :: errorCount
integer(kind=ahi_sint) :: outCount
! /* count-radiance conversion equation */
real(kind=ahi_dreal) :: gain_cnt2rad
real(kind=ahi_dreal) :: cnst_cnt2rad
end type himawari_t_Calib_Info
! Specific calibration info for the IR bands
type :: himawari_t_IR_Calib_Info
real(kind=ahi_dreal) :: rad2btp_c0
real(kind=ahi_dreal) :: rad2btp_c1
real(kind=ahi_dreal) :: rad2btp_c2
real(kind=ahi_dreal) :: btp2rad_c0
real(kind=ahi_dreal) :: btp2rad_c1
real(kind=ahi_dreal) :: btp2rad_c2
real(kind=ahi_dreal) :: lightSpeed
real(kind=ahi_dreal) :: planckConst
real(kind=ahi_dreal) :: bolzConst
character*40 :: spare
end type himawari_t_IR_Calib_Info
! Specific valib info for the VIS/NIR bands
type :: himawari_t_VIS_Calib_Info
real(kind=ahi_dreal) :: rad2albedo
real(kind=ahi_dreal) :: CalUpdTime
real(kind=ahi_dreal) :: Upd_gain_cnt2rad
real(kind=ahi_dreal) :: Upd_cnst_cnt2rad
character*80 :: spare
end type himawari_t_VIS_Calib_Info
type :: himawari_t_InterCalib_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
real(kind=ahi_dreal) :: gsics_cal_off
real(kind=ahi_dreal) :: gsics_cal_slo
real(kind=ahi_dreal) :: gsics_cal_quad
real(kind=ahi_dreal) :: gsics_radbias
real(kind=ahi_dreal) :: gsics_radbias_uncert
real(kind=ahi_dreal) :: gsics_standard_rad
real(kind=ahi_dreal) :: gsics_valid_start
real(kind=ahi_dreal) :: gsics_valid_end
real(kind=ahi_sreal) :: gsics_radlim_upper
real(kind=ahi_sreal) :: gsics_radlim_lower
character*128 :: gsicsCorrInfo
character*56 :: spare
end type himawari_t_InterCalib_Info
! Per-segment info. Is constant so we ignore it
type :: himawari_t_Segm_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
integer(kind=ahi_byte) :: totalSegNum
integer(kind=ahi_byte) :: segSeqNo
integer(kind=ahi_sint) :: strLineNo
character*40 :: spare
end type himawari_t_Segm_Info
! Navigation correction data
type :: himawari_t_NaviCorr_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
real(kind=ahi_sreal) :: RoCenterColumn
real(kind=ahi_sreal) :: RoCenterLine
real(kind=ahi_dreal) :: RoCorrection
integer(kind=ahi_sint) :: correctNum
integer(kind=ahi_sint), allocatable, dimension(:) :: lineNo
real(kind=ahi_sreal), allocatable, dimension(:) :: columnShift
real(kind=ahi_sreal), allocatable, dimension(:) :: lineShift
character*40 :: spare
end type himawari_t_NaviCorr_Info
! Observation info, useful for computing SZA/SAA
type :: himawari_t_ObsTime_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
integer(kind=ahi_sint) :: obsNum
integer(kind=ahi_sint), allocatable, dimension(:) :: lineNo
real(kind=ahi_dreal), allocatable, dimension(:) :: obsMJD
character*40 :: spare
end type himawari_t_ObsTime_Info
! We read but do not use this
type :: himawari_t_Error_Info
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_lint) :: BlockLen
integer(kind=ahi_sint) :: errorNum
integer(kind=ahi_sint), allocatable, dimension(:) :: lineNo
integer(kind=ahi_sint), allocatable, dimension(:) :: errPixNum
character*40 :: spare
end type himawari_t_Error_Info
! For future use
type :: himawari_t_Spare
integer(kind=ahi_byte) :: HeaderNum
integer(kind=ahi_sint) :: BlockLen
character*256 :: spare
end type himawari_t_Spare
!/* navigation correction information table */
type :: himawari_t_Correct_Table
character :: flag
integer(kind=ahi_sint) :: startLineNo
integer(kind=ahi_sint) :: lineNum
real(kind=ahi_sreal) :: cmpCoff
real(kind=ahi_sreal) :: cmpLoff
end type himawari_t_Correct_Table
! Header structure for the IR channels
type :: himawari_t_IR_Header
type(himawari_t_Basic_Info) :: him_basic
type(himawari_t_Data_Info) :: him_data
type(himawari_t_Proj_Info) :: him_proj
type(himawari_t_Navi_Info) :: him_nav
type(himawari_t_Calib_Info) :: him_calib
type(himawari_t_IR_Calib_Info) :: him_chan_calib
type(himawari_t_InterCalib_Info):: him_interCalib
type(himawari_t_Segm_Info) :: him_seg
type(himawari_t_NaviCorr_Info) :: him_navcorr
type(himawari_t_ObsTime_Info) :: him_obstime
type(himawari_t_Error_Info) :: him_error
type(himawari_t_Spare) :: him_spare
type(himawari_t_Correct_Table) :: him_correct_table
end type himawari_t_IR_Header
! Header structure for the VIS channels
type :: himawari_t_VIS_Header
type(himawari_t_Basic_Info) :: him_basic
type(himawari_t_Data_Info) :: him_data
type(himawari_t_Proj_Info) :: him_proj
type(himawari_t_Navi_Info) :: him_nav
type(himawari_t_Calib_Info) :: him_calib
type(himawari_t_VIS_Calib_Info) :: him_chan_calib
type(himawari_t_InterCalib_Info):: him_interCalib
type(himawari_t_Segm_Info) :: him_seg
type(himawari_t_NaviCorr_Info) :: him_navcorr
type(himawari_t_ObsTime_Info) :: him_obstime
type(himawari_t_Error_Info) :: him_error
type(himawari_t_Spare) :: him_spare
type(himawari_t_Correct_Table) :: him_correct_table
end type himawari_t_VIS_Header
end module himawari_headerinfo