




已阅读5页,还剩28页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
一、MODIS Ocean Level 3 Binned Data读取程序IDL语言程序1、 从HDF文件中读取SDSFunction Get_SDS, file_name, SDS_Name If (N_Elements( file_name ) eq 0) then Message, Must specify filename. Id = HDF_SD_Start( file_name, /READ ) Index = HDF_SD_NameToIndex( Id, SDS_Name ) SDS = HDF_SD_Select( Id, Index ) HDF_SD_GetData, SDS, Data HDF_SD_End, Id Return, DataEnd2、 从一个byte中提取1个或多个bit的资料; The IDL function, B, extracts bits from an array of byte values.; i = array of byte values; j = starting bit position; k = number of bits to be extracted; Kevin Turpie, SAIC GSOFunction Bit, i, j, k If (N_Elements( k ) eq 0) then k = 1 k = Fix( k ) If (N_Elements( j ) eq 0) then j = 1 j = Fix( j ) Return, IShft ( IShft ( Long (i), 32-j-k+1 ), -(31-k+1) )End3、 将二进制资料转换成经纬度坐标; This code converts bin number to (lat,lon) ; It is written in both C and IDL.; The IDL routine, , calls a C handler, binloc.c, which in turn; calls the bin2ll routine from a shareable library, created from bin_csub.c; (originally from SeaDAS). Compilation instructions in the binloc.c file; work for SGI. references a .so library file created using those; instructions. The user must be careful to correctly specify the path and; name of this library file for their system in .;- IDL Interface: -;-; BinLoc; This IDL procedure takes an array of L3 bin numbers (b) and returns the; corresponding latitude and longitude values.; ARGUMENTS:; b = corresponding array of bin numbers; Lat = lat/lon grid containing sum of values; Lon = lat/lon grid containing number of values; KEYWORDS:; NROWS = number of rows in input L3 bin grid.; default is 4320 for MODIS. for SeaWiFS, set to 2160.; AUTHOR: Kevin Turpie, 08 May 2000; SAIC General Sciences Corporation; ;- PRO BinLoc, b, Lat, Lon, NROWS=nrows;On_Error, 2 If (N_Elements( nrows ) eq 0) then nrows = 4320L nb = N_Elements( b ) b = Long( b ) nbins = nb nl = N_Elements( Lat ) If (nl eq 0) then begin Lat = FltArr( nb ) nl = nb EndIf If (nl ne nb) then Message, Bin and Lat array must be the same size. Lat = Float( Lat ) nl = N_Elements( Lon ) If (nl eq 0) then begin Lon = FltArr( nb ) nl = nb EndIf If (nl ne nb) then Message, Bin and Lon array must be the same size. Lon = Float( Lon ) iret = Call_External( binloc.so, binloc, $ b, Long( nbins ), Long( nrows), Lat, Lon ) END#include /* binloc (private)!C-* Description: binloc is a routine that can be called from IDL to convert L3 bin numbers into latitude and longitude coordinates. In IDL, call_external is used to pass information via the arguments argc and argv (see below). An IDL routine called was created to handle this routine. Input Parameters: argc number of arguments. argv array of input and output parameters passed by value by call_external in IDL. The elements are described below. Element I/O Description argv0 I corresponding array of bin numbers argv1 I total number of bins argv2 I number of rows in bin grid argv3 O array containing latitude values argv4 O array containing longitude values Output Parameters: void Revision History: Revision 01.00 2000/05/08 17:22:00 K. TURPIE () AUTHOR Team-unique Header: References and Credits: Design Notes: Uses the SeaDAS routines bin_init and bin2ll in the source bin_csub.c or library libsdsbin.a To compile use: cc -32 -shared -KPIC -o binloc.so binloc.c libsdsbin.a or cc -32 -KPIC -c binloc.c cc -32 -KPIC -c bin_csub.c cc -32 -shared -o binloc.so binloc.o bin_csub.o or cc -32 -KPIC -c binloc.c cc -32 -shared -o binloc.so binloc.o libsdsbin.a!END-*/-C Code follows:-binloc.c (C handling for IDL routine binloc; calls bin2ll to do the job.)void binloc( int argc, void *argv ) long i, j, k, a, *b, nbins, nrows, *nbin, *bbin, tbin; float *lbin, *lat, *lon; b = (long *) argv0; nbins = *(long *) argv1; nrows = *(long *) argv2; lat = (float *) argv3; lon = (float *) argv4; bin_init( nrows, &nbin, &bbin, &lbin, &tbin ); for ( k=0; k nbins; k+ ) bin2ll( bk, &(latk), &(lonk) );bin_csub.c is taken from SeaDAS. bin2ll below does the conversion./* This file contains all subroutines for the seawifs level 3 binning*/#include #include #include #definePI3.141592653589793/* global variables only used inside this file, the call to bin_init may pass these variables to the calling routineNUMROWS : total number of rows for binning *NUMBIN: no. of bin in each row *BASEBIN: 1st bin of each row TOTBINS: total bin numbers *LATBIN: center latitude of each row */static long *NUMBIN, *BASEBIN;static float *LATBIN;static long TOTBINS;static long NUMROWS;static float SEAM_LON;/* bin_init: given the total row number, this subroutine returns above variables.*/int bin_init(nrow, nbin, bbin, lbin, tbin)long nrow;long *nbin, *bbin, *tbin;float *lbin; int i; double radfac; static int first=1; if (first = 0) /* free the memory if not the first call */ free(NUMBIN); free(BASEBIN); free(LATBIN); SEAM_LON = -180.0; /* this value should be passed in */ NUMROWS = nrow; NUMBIN = (long *) calloc(NUMROWS, sizeof(long); BASEBIN = (long *) calloc(NUMROWS, sizeof(long); LATBIN = (float *) calloc(NUMROWS, sizeof(float); radfac = PI / 180.0; for (i=0; iNUMROWS; i+) *(LATBIN+i) = (i + 0.5) * (180.0 / NUMROWS) - 90.0; *(NUMBIN+i) = (long) (cos(*(LATBIN+i)*radfac) * (2.0 * NUMROWS) + 0.5); *BASEBIN = 1; for (i=1; i 0 & *(BASEBIN+old_row-1) bin) row = old_row; else if (bin TOTBINS) bin = TOTBINS; /* north pole */ /* binary search for row in range 1.NUMROWS */ rlow = 1; /* 1-relative */ rhi = NUMROWS; /* 1-relative */ while (1) rmid = (rlow + rhi - 1) / 2; /* 0-relative */ if (*(BASEBIN+rmid) bin) rhi = rmid; else rlow = rmid + 1; if (rlow = rhi) row = rlow; break; old_row = row; *lat = *(LATBIN+row-1); *lon = 360.0 * (bin - *(BASEBIN+row-1) + 0.5) / *(NUMBIN+row-1); *lon = *lon + SEAM_LON; /* note, *lon returned here may be in 0 to 360 */* given the lat/lon, return the bin number lon has to be in the range of -180.0 to 180.0*/int ll2bin(lat, lon, bin)float lat, lon;long *bin; /* 1-relative */ long row, col; /* 0-relative */ row = (long) (90.0 + lat) * (float) NUMROWS / 180.0); col = (long) (float) (*(NUMBIN+row) * (lon - SEAM_LON) / 360.0); *bin = *(BASEBIN+row) + col;/* given the lat/lon, return the row, column lon has to be in the range of -180.0 to 180.0 6/96. Cast double in order to get same bin #s for SeaWiFS smap9 and SeaDAS smigen.*/int ll2rc(lat, lon, row, col)float lat, lon;long *row, *col; /* 1-relative */ *row = (long) (90.0 + (double) lat) * (double) NUMROWS / 180.0); *col = (long) (double) (*(NUMBIN + (*row) * (double) lon - SEAM_LON) / 360.0); *row = *row + 1; *col = *col + 1; /* given row/column, return lat/lon*/int rc2ll(row, col, lat, lon)long row, col; /* 1-relative */float *lat, *lon; *lat = *(LATBIN+row-1); *lon = SEAM_LON + (360.0 * (col - 0.5) / *(NUMBIN+row-1);/* given a row/column number, return the bin number (1-relative) */int rc2bin(row, col, bin)long row, col, *bin; *bin = *(BASEBIN+row-1) + col - 1;/* given a bin number, return the row and column (both are 1-relative) heuristic and binary search algorithm is used*/int bin2rc(bin, row, col)long bin; /* 1-relative */long *row, *col; /* 1-relative */ long rlow, rhi, rmid; static long old_row=0; /* 1-relative */ if (old_row 0 & *(BASEBIN+old_row-1) bin) *row = old_row; else if (bin TOTBINS) bin = TOTBINS; /* north pole */ /* binary search for row in range 1.NUMROWS */ rlow = 1; /* 1-relative */ rhi = NUMROWS; /* 1-relative */ while (1) rmid = (rlow + rhi - 1) / 2; /* 0-relative */ if (*(BASEBIN+rmid) bin) rhi = rmid; else rlow = rmid + 1; if (rlow = rhi) *row = rlow; break; old_row = *row; *col = bin - *(BASEBIN + (*row) - 1) + 1;/* given a bin number, return the center lat/lon of that bin number no heuristic or binary search algorithm is used this routine is very slow due to the array reference (I think)*/*int old_bin2ll(bin, lat, lon)long bin;float *lat, *lon; long row; row = NUMROWS-1; while (bin BASEBINrow) row-; *lat = LATBINrow; *lon = 360.0 * (bin - BASEBINrow + 0.5) / NUMBINrow;*/* update version, much faster than using array reference */int old_bin2ll(bin, lat, lon)long bin;float *lat, *lon; long row; long *tmpptr; row = NUMROWS - 1; tmpptr = BASEBIN + NUMROWS - 1; while (bin 0)+2 ) qkey = StrMid( qkey, 0, Mpos )+Q+StrMid( qkey, Mpos+1, lq-Mpos )+* If ( (StrMid( qkey, (pathpos0)+3, 2 ) eq AP) or $ (StrMid( qkey, (pathpos0)+3, 2 ) eq SP) ) then begin; Its an
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年金融反欺诈技术升级与大数据应用趋势分析报告
- 艺术品数字化交易平台市场竞争力分析报告2025
- 2025年事业单位工勤技能-江西-江西药剂员一级(高级技师)历年参考题库含答案解析(5套)
- 2025年事业单位工勤技能-广西-广西计算机信息处理员三级高级历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-广西-广西图书资料员三级(高级工)历年参考题库含答案解析
- 2025年事业单位工勤技能-广东-广东放射技术员四级(中级工)历年参考题库含答案解析
- 2020-2025年房地产估价师之开发经营与管理高分通关题型题库附解析答案
- 2025年事业单位工勤技能-北京-北京信号工-机车信号设备维修五级(初级工)历年参考题库典型考点含答案解析
- 2025年银行金融类-金融考试-银行业专业人员中级(法规+公司信贷)历年参考题库含答案解析(5套)
- 2025年职业技能鉴定-劳动关系协调员-劳动关系协调员技师(二级)历年参考题库含答案解析(5套)
- 2025晋中祁县司法协理员招聘笔试备考试题及答案解析
- 农村自建房租房合同范本
- 虚拟化平台日常运维指南与规范
- 2024年梅州市公务员考试行测真题附答案详解(典型题)
- 2025家电购销合同范本
- (2025)纪检监察应知应会试题库与参考答案
- 非煤矿职工职业卫生培训
- 社区居民高血压防治健康讲座
- 2025年湖北省中考化学试题深度解读及答案详解
- 2025年内蒙古中考语文试卷真题及答案详解(精校打印)
- Unit 3 Same or DifferentSection A Grammar Focus (3a-3c) 课件-2025-2026学年人教版八年级英语上册
评论
0/150
提交评论