2A23 USER'S GUIDE This document has 2 parts: 2A23 ver. 5.5 and Attached document to TRMM PR algorithm 2A23 ver. 5.3 -------------- 2A23 ver. 5.5 -------------- Contents of 2a23-ver5.5.tar: README.v5.5 ----- this file. L2A23main.c L2A23Hpattern.c L2A23rtypes.c L2A23.h TS_29 ----- No changes TS_2A23_29.h ----- No changes make.L2A23 data/2A23.19980203.01059.HDF.Z ---- sample 2a23 HDF file(*) data/VI.19980203.01059 ---- sample VI file(*) (*) These sample files in the 'data' directory ware generated using eoc_result/PR1C21.19980203.01059 which seems to contain the following strange data: For a very few case of minEchoFlag[j]=14, binStormHeight[j][0]=-9999, ---- possible height binStormHeight[j][1]>0 ---- certain height (No possible height but height is certain sounds strange to me.) /******************/ /*** IMPORTANT ***/ /******************/ VERSION_NO and PRODUCT_NO are written at the beginning part (after the HISTORY) of L2A23main.c If VERSION_NO="5.5" and PRODUCT_NO=5 are not appropriate, please change the numbers on the following two lines: #define VERSION_NO "5.5" /* Algorithm version number */ #define PRODUCT_NO 5 /* Product version number */ (Please make sure that the switch EOC_OR_TSDIS is set to 1 #define EOC_OR_TSDIS 1 /* 0 if TSDIS, 1 if EOC */ otherwise VERSION_NO and PRODUCT_NO will not be written to the 2A23 HDF file.) ---------------------------- Major changes from ver. 5.3: ---------------------------- 1) Deleted L2A23clutter-patch.c. 2) New rain types are added (see the list below). With this change, rain types by V- and H-methods and warmRain flag become independent. 3) BB window is expanded. (The width of BB search window defined by Dh in L2A23.h was changed as follows: #define Dh 2.5 /* Width of BB window [km] --- was 1.5 */ where Dh*2 [km] is the width for the BB search. (BB search region changed from +-1.5 to +-2.5 in this trial version.) Check for anvil is introduced; otherwise, some anvil is regarded as a very high BB, which is unacceptable. 4) Changed sidelobe rejection code. 5) Changed some VI file messages. /* ============== */ /* Usage */ /* ============== */ TS_2A23_29.h and sst-hou.grd should be placed in the working directory. It may also be requested that TS_29 should be located at TSDIS toolkit include directory. Usage of L2A23 Please compile L2A23 in the following way: (First, you need to edit the makefile make.L2A23.) make -f make.L2A23 Then run L2A23main as follows: L2A23main <1C21 file id> <2A23 output file id > ===================================== List of rain types in the new version ===================================== * (merged) rainType[i] * = 10: Stratiform certain. * When R_type_V[i] = T_stra; (BB exists) * and R_type_H[i] = T_stra; * * 11: Stratiform certain. * When R_type_V[i] = T_stra; (BB exists) * and R_type_H[i] = T_others; * (or, on a very rare occasion, when only R_type_V[i] is * available because of read scan error.) * * 12: Probably stratiform. * When R_type_V[i] = T_others;(BB may exist but not detected) * and R_type_H[i] = T_stra; * * 13: Maybe stratiform. * When R_type_V[i] = T_stra; (BB detection certain) * and R_type_H[i] = T_conv; * * 14: Maybe stratiform or maybe transition or something else. * ---------- added * When R_type_V[i] = T_others; (BB hardly expected) * and R_type_H[i] = T_stra; * * 15: Maybe stratiform: ---------- added * Shallow isolated (type of warm rain) is detected. * When R_type_V[i] = T_others; * R_type_H[i] = T_stra; * and warmRain[i] > 0; * * 20: Convective certain. * When R_type_V[i] = T_conv; (no BB) * and R_type_H[i] = T_conv; * * 21: Convective certain. * When R_type_V[i] = T_others; * and R_type_H[i] = T_conv; * * 22: Convective certain. * When R_type_V[i] = T_conv; * and R_type_H[i] = T_others; * (or, on a very rare occasion, when only R_type_V[i] is * available because of read scan error.) * * 23: Probably convective. * When R_type_V[i] = T_conv; (BB exists) * and R_type_H[i] = T_conv; * * 24: Maybe convective. * When R_type_V[i] = T_conv; * and R_type_H[i] = T_stra; * * 25: Maybe convective. * When R_type_V[i] = T_stra; (BB detection not so * and R_type_H[i] = T_conv; confident) * * 26: Maybe convective. ---------- added * Shallow isolated (type of warm rain) is detected. * When R_type_V[i] = T_conv, * R_type_H[i] = T_conv; * and warmRain[i] > 0; * * 27: Maybe convective. ---------- added * Shallow isolated (type of warm rain) is detected. * When R_type_V[i] = T_conv, * R_type_H[i] = T_others; * and warmRain[i] > 0; * * 28: Maybe convective. ---------- added * Shallow isolated (type of warm rain) is detected. * When R_type_V[i] = T_others, * R_type_H[i] = T_conv; * and warmRain[i] > 0; * * 29: Maybe convective. ---------- added * Shallow isolated (type of warm rain) is detected. * When R_type_V[i] = T_conv, * R_type_H[i] = T_stra; * and warmRain[i] > 0; * * 30: Others. * When R_type_V[i] = T_others; * and R_type_H[i] = T_others; * This category includes very weak echo (possibly noise) * and/or cloud (very weak echo in the lower altitude but * appreciable echo in the upper part, which was not * detected as bright band). * * 31: Others. ---------- added * Shallow isolated (type of warm rain) is detected. * When R_type_V[i] = T_others, * R_type_H[i] = T_others; * and warmRain[i] > 0; /* ---------------------------------------------------- */ Attached document to TRMM PR algorithm 2A23 ver. 5.3 /* ---------------------------------------------------- */ Jun Awaka Hokkaido Tokai University Minami-ku, Minami-sawa 5-1-1-1 Sapporo 005, Japan tel: +81-11-571-5111 fax: +81-11-571-7879 Email: awaka@de.htokai.ac.jp July 31, 1998. 1. Introduction The TRMM PR standard algorithm 2A23 ver. 5.3 is for a September release of PR data to the public. This document consists of two major part: (1) manual in the next section and (2) some details. ---------------------------- 2. Manual (very first draft) ---------------------------- Perhaps the best way to understand how to use 2A23 HDF file is to run a sample program and inspect the result. Hence, I put a source code of sample program in APPENDIX as follows: APPENDIX 1 shows a source code for test program (read-2a23.c), and APPENDIX 2 shows a makefile for compiling and linking of the test program. 2.1 How to run a sample program To run the test program, you need to install HDF library (HDF4.0r2) and TSDIS toolkit library (toolkit_4.7) in your UNIX machine beforehand. Then go on as follows: (1) Change the makefile in APPENDIX 2 appropriately to your environment. (Please make sure that the environment parameter TSDISTK is properly set. See the toolkit documents for details.) (2) Type in as follows: make -f make.read-2a23 Then the executable file read-2a23 is made. (3) Run the test program as follows: read-2a23 <2A23 HDF file> start stop where 'start' means the scan number from which you wish to begin to examine the data, and 'stop' means the scan number at which your inspection is terminated. Please note that these numbers are counted starting from 0 (not from 1, as in the case of FORTRAN). 2.2 Example The following shows an example of print-out obtained by running the sample program. See section 3.5 for the meaning of each item. awaka% read-2a23 2A23.19971219.00336 2970 2970 algorithmID = 2A23 Input HDF file = 2A23.19971219.00336 ---- core metadata ------ rangeType = Continuous Range input files = PR1C21.19971219.00336 granule ID = 2A23.19971219.00336 data ID = NULL orbitNumber = 0 begin_date= 1997 12 19 begin_time= 3 48 43 end_date= 1997 12 19 end_time= 5 20 1 --------------------------- missingData = 0 percentBadMissPix = 8.95% i_end =9138 scan # = 2970 latitude 16.0 15.9 15.9 15.9 15.8 15.8 15.8 15.7 15.7 15.7 15.6 15.6 15.6 15.5 15.5 15.5 15.4 15.4 15.4 15.3 15.3 15.3 15.2 15.2 15.2 15.1 15.1 15.1 15.0 15.0 15.0 14.9 14.9 14.9 14.8 14.8 14.8 14.7 14.7 14.7 14.6 14.6 14.6 14.5 14.5 14.5 14.4 14.4 14.4 longitude 135.5 135.5 135.5 135.5 135.6 135.6 135.6 135.6 135.7 135.7 135.7 135.7 135.7 135.8 135.8 135.8 135.8 135.9 135.9 135.9 135.9 135.9 136.0 136.0 136.0 136.0 136.0 136.1 136.1 136.1 136.1 136.2 136.2 136.2 136.2 136.2 136.3 136.3 136.3 136.3 136.4 136.4 136.4 136.4 136.4 136.5 136.5 136.5 136.5 read_data.rainFlag 20 20 20 20 20 20 20 20 20 20 20 0 0 0 0 0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 0 0 0 10 10 10 10 10 10 0 0 0 0 0 0 10 read_data.rainType 21 12 12 20 24 20 20 20 20 20 20 -88 -88 -88 -88 -88 12 21 13 13 13 20 20 10 10 12 12 12 10 12 12 12 30 -88 -88 -88 30 30 30 30 30 30 -88 -88 -88 -88 -88 -88 30 read_data.warmRain 0 0 0 0 0 0 0 0 0 0 0 -88 -88 -88 -88 -88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -88 -88 -88 0 0 0 0 0 0 -88 -88 -88 -88 -88 -88 0 read_data.status 0 0 0 0 0 0 0 0 0 0 0 -88 -88 -88 -88 -88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -88 -88 -88 0 0 0 0 0 0 -88 -88 -88 -88 -88 -88 0 rangeBinNum for BB -1111 -1111 -1111 -1111 -1111 -1111 -1111 -1111 -1111 -1111 -1111 -8888 -8888 -8888 -8888 -8888 -1111 -1111 113 111 109 -1111 -1111 107 107 -1111 -1111 -1111 111 -1111 -1111 -1111 -1111 -8888 -8888 -8888 -1111 -1111 -1111 -1111 -1111 -1111 -8888 -8888 -8888 -8888 -8888 -8888 -1111 read_data.HBB -1111 -1111 -1111 -1111 -1111 -1111 -1111 -1111 -1111 -1111 -1111 -8888 -8888 -8888 -8888 -8888 -1111 -1111 4860 4864 4868 -1111 -1111 4625 4625 -1111 -1111 -1111 4494 -1111 -1111 -1111 -1111 -8888 -8888 -8888 -1111 -1111 -1111 -1111 -1111 -1111 -8888 -8888 -8888 -8888 -8888 -8888 -1111 read_data.BBintensity -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -8888.0 -8888.0 -8888.0 -8888.0 -8888.0 -1111.0 -1111.0 33.8 37.3 35.4 -1111.0 -1111.0 36.9 35.0 -1111.0 -1111.0 -1111.0 23.0 -1111.0 -1111.0 -1111.0 -1111.0 -8888.0 -8888.0 -8888.0 -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -1111.0 -8888.0 -8888.0 -8888.0 -8888.0 -8888.0 -8888.0 -1111.0 read_data.freezH 4673 4676 4678 4680 4681 4683 4685 4687 4689 4690 4692 -8888 -8888 -8888 -8888 -8888 4698 4698 4698 4698 4698 4698 4698 4698 4698 4698 4698 4698 4698 4698 4698 4698 4698 -8888 -8888 -8888 4698 4698 4698 4698 4698 4698 -8888 -8888 -8888 -8888 -8888 -8888 4701 read_data.stormH 6063 6686 12106 13235 14852 11510 10940 10119 7336 5149 3073 -8888 -8888 -8888 -8888 -8888 4600 8464 9595 10352 9612 9368 8247 8874 8375 9124 8497 3373 5243 5738 5608 5726 -1111 -8888 -8888 -8888 -1111 -1111 -1111 -1111 -1111 -1111 -8888 -8888 -8888 -8888 -8888 -8888 -1111 where the unit of latitude and longitude is [degrees], the unit of the height of bright band (HBB) is [m], the unit of the strength of bright band (BBintensity) is [dBZ], the unit of the height of freezing level (freezH) is [m], and the unit of the height of storm top (stormH) is [m]. All the heights are those measured from the ellipsoid. 2.3 Some tips (1) 2A23 carries out the detection of bright band and rain type classification when rainFlag = 20 (i.e., rain certain) only. When rainFlag = 10, 11, or 12 (i.e., rain possible), 2A23 skips the bright band detection, and rain type is automatically classified as 'other' type (rainType=30). Therefore, what you should pay attention to is the angle bin data where rainFlag = 20. (2) Rain type is stratiform when rainType = 1x, convective when rainType=2y, and other type when rainType=30, where x, and y indicate a level of confidence. Better not to be bothered by x, and y. It would be wise to just look at the first digit of rainType and see what type of rain it is. In other words, use the following logic in your program. Then you can obtain the rain type with three categories. When rainType[i] > 0, rainType[i] / 10 = 1: stratiform, 2: convective, 3: others. (3) Important Note: When rainFlag = 20 (i.e., rain certain) and rainType = 30 (i.e., other type), it sometimes indicates that there exists cold thick cloud. 2.4 Caution (1) Only when rainType>0 (i.e., rain exists or rain possible), estimated height of freezing level (freezH) is computed and written in the output of 2A23 HDF file. ---------- 3. Details ---------- 3.1. Major changes Major changes from the previous version are as follows: (1) New items (BBintensity[49] and spare[49]) are added to the 2A23 output. (2) Sidelobe clutter rejection is introduced. (3) Bright band detection strategy is changed. (4) Isolation condition for warm rain is changed (to be more conservative). (5) Some apparent deficiency in the 1B21 clutter rejection routine is covered by a Level-2 patch program. 3.2. Input files (a) 1C21 HDF file (b) sst-hou.grd 3.3. Output file (a) 2A23 HDF file (b) VI file (ascii text file for diagnostic purposes) 3.4. Usage of L2A23 First, install HDF4.0r2 and TSDIS Toolkit_4.7. Please make sure that the surface temperature file sst-hou.grd is located in the current directory. Next, put (copy or move) TS_29 at the include directory of TSDIS toolkit. In the current directory where all the 2A23 source files exist, compile the 2A23 sources by make -f make.L2A23 and run L2A23main as follows: L2A23main <1C-21 HDF file> <2A-23 HDF file> where VI file is a verification intermediate file (text file), which stores error/warning messages to be used for diagnostic purposes. 3.5. Output data (1) metadata (2) L2A_23_SWATHDATA (a) scanTime: Same as that of 1C21 (b) geolocation[49][2]: Same as that of 1C21 (c) scanStatus: Same as that of 1C21 (d) navigate: Same as that of 1C21 (e) int8 rainFlag[49]: Almost identical to minEchoFlag of 1C21 = 0 : no rain 10 : rain possible 11 : rain possible 12 : rain possible 20 : rain certain -99 : data missing (The above is different from ICS, volume 4, release 3.) (f) int8 rainType[49]: In ver, 5.3, the rainType[j] (j=0 to 48) is the unified rain type as follows: rainType[j] = 10: Stratiform certain. When R_type_V[i] = T_stra; (BB exists) and R_type_H[i] = T_stra; 11: Stratiform certain. When R_type_V[i] = T_stra; (BB exists) and R_type_H[i] = T_others; 12: Probably stratiform. When R_type_V[i] = T_others; and R_type_H[i] = T_stra; 13: Maybe stratiform. When R_type_V[i] = T_stra; (BB detection certain) and R_type_H[i] = T_conv; 20: Convective certain. When R_type_V[i] = T_conv; (no BB) and R_type_H[i] = T_conv; 21: Convective certain. When R_type_V[i] = T_others; and R_type_H[i] = T_conv; 22: Convective certain. When R_type_V[i] = T_conv; and R_type_H[i] = T_others; 23: Probably convective. When R_type_V[i] = T_conv; (BB exists) and R_type_H[i] = T_conv; 24: Maybe convective. When R_type_V[i] = T_conv; and R_type_H[i] = T_stra; 25: Maybe convective. When R_type_V[i] = T_stra; (BB detection not so and R_type_H[i] = T_conv; confident) 30: Others. When R_type_V[i] = T_others; and R_type_H[i] = T_others; where R_type_V: rain type classified by the V-profile method, R_type_H: rain type classified by the H-pattern method, which is based on SHY95 developed by Prof. Houze and his group. The above assignment of numbers has the following meaning: When rainType[i] > 0, rainType[i] / 10 = 1: stratiform, 2: convective, 3: others. rainType[i] % 10 = This indicates the level of confidence, which decreases as the number increases. where rainType[i] % 10 means MOD(rainType[i],10) in FORTRAN. When it is "no rain" or "data missing", rainType[j] contains the following values: -88 : no rain -99 : data missing <> By the sample code below, rain type would be stored in type[i] and its level of confidence (0:certain, 1:probably, 2:maybe) in conf_level[i]. (Error handling, however, is omitted in the sample code below, so that the users must add an appropriate error check by themselves.) if (rainType[i]>0) { type[i] = rainType[i] / 10; i_conf = rainType[i] % 10; if (type[i]==1) { if (i_conf<2) { conf_level[i] = 0; /* stratiform certain */ } else if (i_conf==2) { conf_level[i] = 1; /* probably stratiform */ } else { conf_level[i] = 2; /* maybe stratiform */ } } if (type[i]==2) { if (i_conf<3) { conf_level[i] = 0; /* convective certain */ } else if (i_conf==3) { conf_level[i] = 1; /* probably convective */ } else { conf_level[i] = 2; /* maybe convective */ } } else { conf_level[i] = 0; /* other certain */ } } (The above is different from ICS, volume 4, release 3.) (g) int8 warmRain[49]: Warm rain flag = 0 : no warm rain 1 : Maybe warm rain 2 : Warm rain (with confidence) -88 : no rain -99 : data missing (no rain and data missing are added to warmRain values described in ICS, volume 4, release 3) (h) int8 status[49]: Status flag for the processing of 2A23 = 0: good (over ocean) 10: BB detection may be good (over ocean) 20: R-type classification may be good (over ocean) (BB detection is good or BB does not exist) 30: Both BB detection and R-type classification may be good (over ocean) 50: not good (because of warnings) (over ocean) 100: bad (possible data corruption) (over ocean) 1: good (over land) 11: BB detection may be good (over land) 21: R-type classification may be good (over land) (BB detection is good or BB does not exist) 31: Both BB detection and R-type classification may be good (over land) 51: not good (because of warnings) (over land) 101: bad (possible data corruption) (over land) 2: good (over coastline) 12: BB detection may be good (over coastline) 22: R-type classification may be good (over coastline) (BB detection is good or BB does not exist) 32: Both BB detection and R-type classification may be good (over coastline) 52: not good (because of warnings) (over coastline) 102: bad (possible data corruption) (over coastline) 4: good (over inland lake) 14: BB detection may be good (over inland lake) 24: R-type classification may be good (over inland lake) (BB detection is good or BB does not exist) 34: Both BB detection and R-type classification may be good (over inland lake) 54: not good (because of warnings) (over inland lake) 104: bad (possible data corruption) (over inland lake) 9: may be good (land/sea unknown) /* added */ 19: BB detection may be good (land/sea unknown) /* added */ 29: R-type classification may be good (land/sea unknown) /* added */ (BB detection is good or BB does not exist) 39: Both BB detection and R-type classification may be good (land/sea unknown) /* added */ 59: not good (because of warnings) (land/sea unknown) /* added */ 109: bad (possible data corruption) (land/sea unknown) /* added */ When it is "no rain" or "data missing", status[j] contains the following values: -88 : no rain -99 : data missing Assignment of the above numbers are based on the following rules: When status >= 0, status / 100 = 0: good, maybe good, or not good. 1: doubtful. (status/10)%10 = 0: good or may be good when status < 100, and bad when status >= 100. 1: BB detection not so confident. 2: R-type classification not so confident (but BB detection is good, or when BB does not exist). 3: BB detection is not so confident and R-type classification not so confident. 5: Over-all quality of the processed data for the j-th scan angle is not good (but may not be too bad to be classified as bad data). status % 10 = 0: over ocean. 1: over land. 2: over coastline. 4: over inland lake. 9: land/sea unknown. /* added in ver. 4.5. */ In other words, we can check the confidence level of 2A23 by the following way: status >= 100 : bad (untrustworthy because of possible data corruption). 100> status >= 10 : result not so confident (warning). status = 9 : may be good. 9> status >= 0 : good. The last digit of status indicates over ocean, land, etc. (The above is different from ICS, volume 4, release 3.) (i) int16 rangeBinNum[49]: Range bin number for the height of bright band. The numbering is conforming to that of 1C-21 normal sample. (see NOTE 1) > 0 : Range bin number. This also indicates that the bright band exits. = -1111 : No bright band = -8888 : No rain = -9999 : Data missing (The above is different from ICS, volume 4, release 3.) (j) int16 HBB[49]: Height of bright band. (see NOTE 1) > 0 : Height of bright band expressed in [m] This also indicates that the bright band exits. = -1111 : No bright band = -8888 : No rain = -9999 : Data missing (The above is different from ICS, volume 4, release 3.) (k) float32 BBintensity[49]: Bright band intensity in dBZ. = -1111.0 : No bright band = -8888.0 : No rain = -9999.0 : Data missing (l) int16 freezH[49]: Height of freezing level estimated from the climatological surface temperature data (sst-hou data). > 0 : Estimated height of freezing level [m] = -5555 : When error occurred in the estimation of freezH /* --- added in ver. 4.5 */ = -8888 : No rain = -9999 : Data missing (The above is different from ICS, volume 4, release 3.) (m) int16 stormH[49]: Height of storm top. (see NOTE 2) > 0 : Height of storm top [m] (with high level of confidence) = -1111 : No stormH with high level of confidence = -8888 : No rain = -9999 : Data missing This height is computed only in the case of rain certain, i.e. minEchoFlag[i]=2. Hence, it is computed by stormH[i] = (binEllipsoid[i] - binStormHeight[i][1])*125*cos(zenith) where zenith is the zenith angle expressed in radian. When rain is possible, i.e. minEchoFlag[i]=1, it is set to the following value: stormH[i] = -1111 (The above is different from ICS, volume 4, release 3.) (n) float32 spare[49]: spare. (Newly added.) NOTE 1: Although 2A23 does not output the BB_flag explicitly, it can be reconstructed from rangeBinNum or from HBB, e.g. in the following way: In the case of C program, it may be something like for (i=0; i<49; i++) { if (HBB[i]>0) { BB_flag[i] = 1; /* bright band exists */ } else { BB_flag[i] = 0; /* No bright band */ } } or in the case of FORTRAN program, it may be something like DO 10 I=1, 49 IF (HBB(I).GT.0) THEN BB_flag(I) = 1 ELSE BB_flag(I) = 0 ENDIF 10 CONTINUE NOTE 2: The most annoying part is in the computation of stormH. 1C21 outputs two kinds of binStormHeight: one with higher level of confidence and the other with lower level of confidence. A straightforward answer to handle this situation is to make 2A23 also output two kinds of stormH. However, I feel that the present file format for 2A23 would be fully acceptable to most users because of the following reason. If the users want to examine a possible storm height with lower level of confidence, they should use 1C21 because the height with lower level of confidence is noise-prone and unreliable, the users have to examine the original Z profile stored in 1C21 anyway. 3.6. Issues (1) Improvement for BB detection is necessary. (2) Extensive validation of 2A23 is necessary. If you have any question, please feel free to contact Jun Awaka Hokkaido Tokai University Minami-ku, Minami-sawa 5-1-1-1 Sapporo 005, Japan Tel: +81-11-571-5111 Fax: +81-11-571-7879 e-mail: awaka@de.htokai.ac.jp -------- APPENDIX -------- ************************** APPENDIX 1 Sample program ************************** /* read-2a23.c (for 2A23 ver. 5.3) */ /* Test program for reading output HDF file of PR 2A-23 (Ver. 5.3) */ /* Author: Jun Awaka, Hokkaido Tokai University. */ /* History: */ /* 1998-07-30 Ver. 5.2 with HDF4.0r2 and toolkit_5.7 */ /* 1997-03-29 Ver. 4.0 with HDF4.0r2 and toolkit_4.0 */ /* 1997-02-26 Ver. 4.0 with HDF4.0r2 and toolkit_3.5.2 */ /* 1996-11-22 Ver. 3.5 beta2 with HDF4.0r2 and toolkit_3.5 */ /* 1996-08-30 Ver. 3.5 with HDF4.0r1 and TSDIS toolkit_3.0 */ /* 1996-03-25 VER. 3.0 with toolkit_2.5 */ /* LANGUAGE: ANSI-C */ #include "IO.h" #include "IO_PR.h" #include "TS_TK_15.h" #include "TKerrHandle.h" #include #include #include #include /* ------ definition of parameters used in 2A-23 ------- */ #define maxrng 140 #define maxangbin 49 /* Missing values */ #define Missing_1C21_I8 -99 #define Missing_I8 -99 #define Missing_I16 -9999 /* No-rain values */ #define No_Rain_HGT -8.888 #define No_Rain_I8 -88 #define No_Rain_I16 -8888 int CRT_out_metadata(IO_HANDLE *granuleHandle2A23) { int i; float x; char parameter[50]; char c[100]; DATE_STR begin_date; DATE_STR end_date; TIME_STR begin_time; TIME_STR end_time; puts("---- core metadata ------"); TKreadMetadataChar(granuleHandle2A23, TK_TEMPOR_RNG_TYPE, c); c[99] = '\0'; printf("rangeType = %s\n", c); TKreadMetadataChar(granuleHandle2A23, TK_INPUT_FILES, c); c[99] = '\0'; printf("input files = %s\n", c); TKreadMetadataChar(granuleHandle2A23, TK_GRANULE_ID, c); c[99] = '\0'; printf("granule ID = %s\n", c); TKreadMetadataChar(granuleHandle2A23, TK_DATA_ID, c); c[99] = '\0'; printf("data ID = %s\n", c); TKreadMetadataInt(granuleHandle2A23, TK_ORBIT_NUMBER, &i); printf("orbitNumber = %d\n", i); TKreadMetadataInt(granuleHandle2A23, TK_BEGIN_DATE, &begin_date); printf("begin_date= %d %d %d\n", begin_date.tkyear, begin_date.tkmonth, begin_date.tkday); TKreadMetadataInt(granuleHandle2A23, TK_BEGIN_TIME, &begin_time); printf("begin_time= %d %d %d\n", begin_time.tkhour, begin_time.tkminute, begin_time.tksecond); TKreadMetadataInt(granuleHandle2A23, TK_END_DATE, &end_date); printf("end_date= %d %d %d\n", end_date.tkyear, end_date.tkmonth, end_date.tkday); TKreadMetadataInt(granuleHandle2A23, TK_END_TIME, &end_time); printf("end_time= %d %d %d\n", end_time.tkhour, end_time.tkminute, end_time.tksecond); puts("---------------------------"); TKreadMetadataInt(granuleHandle2A23, TK_MISSING_DATA, &i); printf("missingData = %d\n", i); TKreadMetadataChar(granuleHandle2A23, TK_PERCENT_BAD_MISS_PIXEL, c); c[99] = '\0'; printf("percentBadMissPix = %s\n", c); return 0; } int CRT_out(L2A_23_SWATHDATA *read_data) { int i, j, k; puts("latitude"); for (j=0; j<49; j++) { printf("%7.1f ", read_data->geolocation[j][0]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("longitude"); for (j=0; j<49; j++) { printf("%7.1f ", read_data->geolocation[j][1]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("read_data.rainFlag"); for (j=0; j<49; j++) { printf("%7d ", read_data->rainFlag[j]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("read_data.rainType"); for (j=0; j<49; j++) { printf("%7d ", read_data->rainType[j]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("read_data.warmRain"); for (j=0; j<49; j++) { printf("%7d ", read_data->warmRain[j]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("read_data.status"); for (j=0; j<49; j++) { printf("%7d ", read_data->status[j]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("rangeBinNum for BB"); for (j=0; j<49; j++) { printf("%7d ", read_data->rangeBinNum[j]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("read_data.HBB"); for (j=0; j<49; j++) { printf("%7d ", read_data->HBB[j]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("read_data.BBintensity"); for (j=0; j<49; j++) { printf("%7.1f ", read_data->BBintensity[j]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("read_data.freezH"); for (j=0; j<49; j++) { printf("%7d ", read_data->freezH[j]); if(j%10==9) putchar('\n'); } putchar('\n'); puts("read_data.stormH"); for (j=0; j<49; j++) { printf("%7d ", read_data->stormH[j]); if(j%10==9) putchar('\n'); } putchar('\n'); /* If you add here a similar lines as above, you can inspect */ /* the content of spare[] if you wish to guess what spare[] is */ /* intended to be. */ return 0; } int main(int argc, char *argv[]) { /* ------------- HDF ----------- */ L2A_23_SWATHDATA read_data; IO_HANDLE granuleHandle2A23; char granuleID_2A23[100]; int dataType_2A23; char filemode_2A23; char parameter[50]; int status; /* ---------- metadata -------- */ DATE_STR begin_date; DATE_STR end_date; TIME_STR begin_time; TIME_STR end_time; char algorithmID[20]; /* ----------------------------- */ int i, j, k; int32 i_end, i_count; int32 i_start, i_stop; /* --------- open input file (HDF) -------- */ if (argc < 4) { fprintf(stderr, "\n Usage: read-2a23 start stop\n\n"); exit(1); } i_start = atoi(argv[2]); i_stop = atoi(argv[3]); strcpy(granuleID_2A23, argv[1]); dataType_2A23 = TK_L2A_23; /* TK_L2A_23 is defined in IO.h */ filemode_2A23 = TK_READ_ONLY; status = TKopen(granuleID_2A23, dataType_2A23, filemode_2A23, &granuleHandle2A23); /* --------- check algorithmID (in metadata) --------- */ status = TKreadMetadataChar(&granuleHandle2A23, TK_ALGORITHM_ID, algorithmID); if(status != TK_SUCCESS) { fprintf(stderr, "Error in reading char-type metadata\n"); TKclose(&granuleHandle2A23); exit(1); } printf("algorithmID = %s\n", algorithmID); printf("Input HDF file = %s\n", granuleID_2A23); /* --------------------- read some metadata ------------------- */ status = TKreadMetadataInt(&granuleHandle2A23, TK_BEGIN_DATE, &begin_date); status += TKreadMetadataInt(&granuleHandle2A23, TK_BEGIN_TIME, &begin_time); status += TKreadMetadataInt(&granuleHandle2A23, TK_END_DATE, &end_date); status += TKreadMetadataInt(&granuleHandle2A23, TK_END_TIME, &end_time); status += TKreadMetadataInt(&granuleHandle2A23, TK_ORBIT_SIZE, &i_end); if(status != TK_SUCCESS) { fprintf(stderr, "Error in reading int-type metadata\n"); TKclose(&granuleHandle2A23); exit(1); } CRT_out_metadata(&granuleHandle2A23); printf("i_end =%ld\n", i_end); if (i_stop>i_end) i_stop = i_end; /* ----------------------------------------- */ if (i_start > 0) { TKseek(&granuleHandle2A23, i_start, TK_ABS_SCAN_OFF); } for (i_count=0; i_count<=(i_stop-i_start); i_count++) { /* ------------- double check of EOF ------------- */ if (TKendOfFile(&granuleHandle2A23)==TK_EOF) break; status = TKreadScan(&granuleHandle2A23, &read_data); /* The following if-block may be meaningless because */ /* TKreadScan seems to exit automatically when error occurs */ if(status != TK_SUCCESS) { fprintf(stderr, "TKreadScan error in the main function \n"); } printf("scan # = %d\n", i_count+i_start); CRT_out(&read_data); } status = TKclose(&granuleHandle2A23); return 0; } ************************************************** APPENDIX 2 Makefile for the above sample program ************************************************** EXEC1 = read-2a23 ############################################################################## MACHINE = SUN CC = cc CFLAGS = -g -D$(MACHINE) -DX_WCHAR LIBES = -ltsdistk -lmfhdf -ldf -ljpeg -lz -lnsl MATHLIB = -lm ########################################################################### HDFINC1 = -I/home/usr0/trmm/tool/hdf4.0r2/include IOINC = -I/home/usr0/trmm/tool/toolkit_4.7/include LIBDIR1 = -L/home/usr0/trmm/tool/hdf4.0r2/lib LIBDIR2 = -L/home/usr0/trmm/tool/toolkit_4.7/lib LIBDIR3 = -L/usr/lib ############################################################################## OBJECTSC= read-2a23.o ############################################################################## all: $(EXEC1) $(EXEC1): $(OBJECTSC) $(CC) -o $(EXEC1) $(OBJECTSC) $(LIBDIR1) $(LIBDIR2)\ $(LIBDIR3) $(MATHLIB) $(LIBES) rm read-2a23.o ############################################################################## read-2a23.o : read-2a23.c $(CC) -c $(CFLAGS) $(HDFINC1) $(IOINC) read-2a23.c