### Install MISR Toolkit Python Interface Python Wrappers Source: https://github.com/nasa/misr-toolkit/blob/master/doc/pymtk/installation.html Navigate to the Python wrapper directory within the MISR Toolkit source and execute the Python setup script to install the interface. This command builds and installs the necessary Python modules. ```Shell cd Mtk/wrappers/python python setup.py install ``` -------------------------------- ### Example Usage of MTK_ORBIT_TO_PATH in IDL Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_orbit_to_path.html Demonstrates how to call MTK_ORBIT_TO_PATH with an orbit number and print the resulting path. Shows input parameter setup and output display. ```IDL ;; ;; Set up input parameters ;; orbit = 29058 status = MTK_ORBIT_TO_PATH( orbit, path ) ;; ;; Output... ;; print, 'orbit : ', orbit print, '=================================================' print, 'PATH : ',path ``` -------------------------------- ### IDL Example: Calling MTK_LATLON_TO_PATHLIST Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_latlon_to_pathlist.html An IDL code example demonstrating how to set up input parameters (latitude, longitude), call the `MTK_LATLON_TO_PATHLIST` routine, and then print the returned latitude, longitude, and the list of intersecting paths. ```IDL ;; ;; Set up input parameters ;; lat = 66.121646 lon = 89.263022 status = MTK_LATLON_TO_PATHLIST( lat, lon, path_cnt, path_list ) ;; ;; Output... ;; print, 'latitude : ', lat print, 'longitude : ', lon print, '=================================================' print, '--- PATH LIST ---' FOR i=0,path_cnt-1 DO print, path_list[i] ``` -------------------------------- ### MtkFindFileList Command-Line Examples Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Examples demonstrating the use of MtkFindFileList for locating MISR files based on various criteria like orbit, product type, path, and version. These snippets show different ways to specify search parameters for the utility. ```Shell --orbit=".*" --ver=F03_0024 MtkFindFileList --dir=. --prod="TC.*" --path=037 --orbit=".*" --ver=".*" ``` -------------------------------- ### Example: Retrieve Coremetadata Parameters for a MISR File (IDL) Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_file_coremetadata_query.html Demonstrates how to use the MTK_FILE_COREMETADATA_QUERY function in IDL to get coremetadata parameters from a MISR product file and print them. It shows setting up the input file path, calling the function, and iterating through the returned parameter list. ```IDL ;; ;; Set up input parameters ;; file = '../Mtk_testdata/in/MISR_AM1_AS_LAND_P037_O029058_F06_0017.hdf' status = MTK_FILE_COREMETADATA_QUERY( file, nparams, paramlist ) ;; ;; Output... ;; print, 'file : ', file print, 'nparams : ', nparams print, '=================================================' FOR i=0,MIN([5,nparams-1]) DO $ PRINT, 'COREMETADATA PARAMETER NAME #'+STRTRIM(i+1,2)+ $ ' = '+paramlist[i] ``` -------------------------------- ### IDL Example: Converting Radians to Degrees, Minutes, Seconds Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_rad_to_deg_min_sec.html Demonstrates how to use the MTK_RAD_TO_DEG_MIN_SEC routine in IDL, showing input setup, function call, and printing the converted output. ```IDL ;; ;; Set up input parameters ;; rad = 1.14406333 status = MTK_RAD_TO_DEG_MIN_SEC( rad, deg, minutes, seconds ) ;; ;; Output... ;; print, 'radians : ', rad print, '=================================================' print, 'DEGREES : ',deg print, 'MINUTES : ',minutes print, 'SECONDS : ',seconds ``` -------------------------------- ### IDL Example: Constructing a MISR Filename with MTK_MAKE_FILENAME Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_make_filename.html Demonstrates how to use the `MTK_MAKE_FILENAME` function in IDL to generate a MISR product filename. It shows parameter setup, function call, and output printing. ```IDL ;; ;; Set up input parameters ;; directory = '../Mtk_testdata/in/' product = 'GRP_ELLIPSOID_GM' camera = 'AA' path = '037' orbit = '029058' version = 'F03_0024' status = MTK_MAKE_FILENAME( directory, product, camera, path, orbit, version, out_filename ) ;; ;; Output... ;; print, 'directory : ', directory print, 'product : ', product print, 'camera : ', camera print, 'path : ', path print, 'orbit : ', orbit print, 'version : ', version print, '=================================================' print, 'OUT FILE NAME : ',out_filename ``` -------------------------------- ### Example Usage of MTK_CREATE_LATLON in IDL Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_create_latlon.html This example demonstrates how to set up input parameters (path, resolution, latitude, longitude, extents), define a region using MTK_SETREGION_BY_LATLON_EXTENT, snap it to a grid with MTK_SNAP_TO_GRID, and then generate latitude and longitude buffers using MTK_CREATE_LATLON. It also shows how to print the input parameters and inspect the generated buffers. ```IDL ;; ;; Set up input parameters ;; path = 37 resolution = 1100 lat = 66.0 lon = -89.0 lat_extent = 1.5 lon_extent = 1.0 status = MTK_SETREGION_BY_LATLON_EXTENT( lat, lon, lat_extent, lon_extent, "degrees", region ) status = MTK_SNAP_TO_GRID( path, resolution, region, mapinfo ) status = MTK_CREATE_LATLON( mapinfo, latbuf, lonbuf ) ;; ;; Output... ;; print, 'path : ', path print, 'resolution : ', resolution help, latbuf, lonbuf ``` -------------------------------- ### Example: Get Field Attributes using MTK_FIELDATTR_LIST (IDL) Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_fieldattr_list.html This IDL example demonstrates how to use the MTK_FIELDATTR_LIST routine to retrieve the number and list of attributes for a specified field within a MISR product file. It shows input parameter setup, the function call, and printing the results. ```IDL ;; ;; Set up input parameters ;; file = '../Mtk_testdata/in/MISR_AM1_TC_CLOUD_P110_O074017_F01_0001.hdf' field = 'CloudMotionCrossTrack' status = MTK_FIELDATTR_LIST( file, field, attrcnt, attrlist ) ;; ;; Output... ;; print, 'file : ', file print, 'field : ', field print, '=================================================' print, 'attribute count : ', attrcnt print, 'attribute list : ', attrlist ``` -------------------------------- ### IDL Example: Applying Regression with MTK_APPLY_REGRESSION Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_apply_regression.html This IDL code example demonstrates the full workflow for using `MTK_APPLY_REGRESSION`. It includes steps for generating synthetic input data, defining a geographic region, calculating regression coefficients using `MTK_REGRESSION_COEFF_CALC`, and finally calling `MTK_APPLY_REGRESSION` to process the data. The example also shows how to inspect the resulting valid masks. ```IDL ;; ;; Set up input parameters ;; data1 = RANDOMU(seed, 512, 704) valid_mask1 = byte(replicate(1,512,704)) data2 = RANDOMU(seed, 512, 704) data2_sigma = RANDOMU(seed, 512, 704) valid_mask2 = byte(replicate(1,512,704)) path = 37 resolution = 275 lat = 66.0 lon = -89.0 lat_extent = 1.5 lon_extent = 1.0 status = MTK_SETREGION_BY_LATLON_EXTENT( lat, lon, lat_extent, lon_extent, "degrees", region ) status = MTK_SNAP_TO_GRID( path, resolution, region, mapinfo ) size_factor = 2 status = MTK_REGRESSION_COEFF_CALC( data1, valid_mask1, data2, data2_sigma, valid_mask2, mapinfo, size_factor, regression_coeff, regression_coeff_map_info ) ;; ;; The call ;; status = MTK_APPLY_REGRESSION( data1, valid_mask1, mapinfo, regression_coeff, regression_coeff_map_info, regressed, regressed_mask ) ;; ;; Output... ;; print, '=================================================' index = WHERE(valid_mask1 EQ 1,count) print, count index = WHERE(regressed_mask EQ 1, count) print, count ``` -------------------------------- ### IDL Example: Get Grid Resolution from MISR File Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_file_grid_to_resolution.html This IDL example demonstrates how to use the `MTK_FILE_GRID_TO_RESOLUTION` routine to obtain the resolution of a 'RedBand' grid from a specified MISR HDF file. It prints the input file, grid, and the resulting resolution. ```IDL ;; ;; Set up input parameters ;; file = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' grid = 'RedBand' status = MTK_FILE_GRID_TO_RESOLUTION( file, grid, resolution ) ;; ;; Output... ;; print, 'file : ', file print, 'grid : ', grid print, '=================================================' print, 'RESOLUTION (meters) : ',resolution ``` -------------------------------- ### Get Orbit and Path for a Specific Time Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Example of MtkTimeToOrbitPath to find the orbit and path corresponding to a specific date and time. ```Shell MtkTimeToOrbitPath 2002-02-02T02:00:00Z ``` -------------------------------- ### IDL Example: Downsampling MISR Data with MTK_DOWNSAMPLE Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_downsample.html This IDL example demonstrates how to use the MTK_DOWNSAMPLE routine. It sets up input parameters by reading MISR data, applies the downsampling function, and then prints information about the original and resampled data arrays. ```IDL ;; ;; Set up input parameters ;; filename = '../Mtk_testdata/in/MISR_AM1_AGP_P039_F01_24.hdf' gridname = 'Standard' fieldname = 'AveSceneElev' path = 39 start_block = 50 end_block = 52 size_factor = 2 status = MTK_SETREGION_BY_PATH_BLOCKRANGE( path, start_block, end_block, region ) status = MTK_READDATA( filename, gridname, fieldname, region, srcbuf, mapinfo ) srcbuf = float(srcbuf) src_mask = byte(replicate(1,528,384)) ;; ;; The call ;; status = MTK_DOWNSAMPLE( srcbuf, src_mask, size_factor, resamp, resamp_mask ) ;; ;; Output... ;; print, '=================================================' help, srcbuf, resamp ``` -------------------------------- ### IDL Example: Determining MISR Block Range from Latitude/Longitude Extent Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_region_path_to_blockrange.html This IDL example demonstrates a complete workflow to obtain the starting and ending MISR blocks for a specific path and a region defined by latitude and longitude extents. It first uses `MTK_SETREGION_BY_LATLON_EXTENT` to create a region structure, then applies `MTK_REGION_PATH_TO_BLOCKRANGE` to calculate the blocks, and finally prints the results to the console. ```IDL ;;\n;; Set up input parameters\n;;\npath = 37\nlat = 66.0\nlon = -89.0\nlat_extent = 10.0\nlon_extent = 10.0\nstatus = MTK_SETREGION_BY_LATLON_EXTENT( lat, lon, lat_extent, lon_extent, "degrees", region )\nstatus = MTK_REGION_PATH_TO_BLOCKRANGE( region, path, start_block, end_block )\n\n;;\n;; Output...\n;;\nprint, 'path : ', path\nprint, 'center latitude : ', lat\nprint, 'center longitude : ', lon\nprint, 'latitudinal extent : ', lat_extent\nprint, 'longitudinal extent : ', lon_extent\nprint, '================================================='\nprint, 'STARTING BLOCK : ', start_block\nprint, 'ENDING BLOCK : ', end_block ``` -------------------------------- ### Example: Get MISR Field Fill Value Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Example command to use `MtkFillValueGet` to retrieve the fill value for a specific field ('Blue Radiance/RDQI') within the 'BlueBand' grid of a MISR HDF file. ```Shell MtkFillValueGet --hdffilename=../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf --gridname=BlueBand --fieldname="Blue Radiance/RDQI" ``` -------------------------------- ### IDL Example: Retrieve MISR File Block Range Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_file_to_blockrange.html Illustrates how to call the MTK_FILE_TO_BLOCKRANGE function in IDL. The example sets a sample MISR file path, executes the function, and then prints the returned starting and ending block numbers to the console. ```IDL ;; ;; Set up input parameters ;; file = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' status = MTK_FILE_TO_BLOCKRANGE( file, start_block, end_block ) ;; ;; Output... ;; print, 'file : ', file print, '=================================================' print, 'STARTING BLOCK : ',start_block print, 'ENDING BLOCK : ',end_block ``` -------------------------------- ### IDL Example Output: MTK_SNAP_TO_GRID Structures Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_snap_to_grid.html This snippet provides the console output from the IDL example, illustrating the structure and content of the 'region' and 'mapinfo' variables after MTK_SNAP_TO_GRID has been executed. It details the various fields within these structures, such as geographic coordinates, block information, and projection parameters. ```IDL path : 37 resolution : 275 ** Structure <5353c0>, 4 tags, length=32, data length=32, refs=1: GEO_CTR_LAT DOUBLE 66.000000 GEO_CTR_LON DOUBLE -89.000000 HEXTENT_XLAT DOUBLE 83489.657 HEXTENT_YLON DOUBLE 55659.772 ================================================= ** Structure <2866210>, 37 tags, length=1064, data length=1064, refs=1: PATH LONG 37 START_BLOCK LONG 36 END_BLOCK LONG 37 RESOLUTION LONG 275 RESFACTOR LONG 1 NLINE LONG 640 NSAMPLE LONG 448 PIXEL_CENTER LONG 1 SOM_PATH LONG 37 SOM_ULC_X DOUBLE 12394112. SOM_ULC_Y DOUBLE 1065762.5 SOM_CTR_X DOUBLE 12481975. SOM_CTR_Y DOUBLE 1127225.0 SOM_LRC_X DOUBLE 12569838. SOM_LRC_Y DOUBLE 1188687.5 GEO_ULC_LAT DOUBLE 66.950041 GEO_ULC_LON DOUBLE -89.380321 GEO_URC_LAT DOUBLE 66.451144 GEO_URC_LON DOUBLE -86.901382 GEO_CTR_LAT DOUBLE 66.001338 GEO_CTR_LON DOUBLE -89.003794 GEO_LRC_LAT DOUBLE 65.052256 GEO_LRC_LON DOUBLE -88.652965 GEO_LLC_LAT DOUBLE 65.523048 GEO_LLC_LON DOUBLE -91.031282 PP_PATH LONG 37 PP_PROJCODE LONG 22 PP_ZONECODE LONG -1 PP_SPHERECODE LONG 12 PP_PROJPARAM DOUBLE Array[15] PP_ULC_BLOCK1 DOUBLE Array[2] PP_LRC_BLOCK1 DOUBLE Array[2] PP_NBLOCK LONG 180 PP_NLINE LONG 512 PP_NSAMPLE LONG 2048 PP_RELOFFSET FLOAT Array[179] PP_RESOLUTION LONG 275 ``` -------------------------------- ### IDL Example: Retrieving MISR File Version Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_file_version.html This IDL example demonstrates how to use the `MTK_FILE_VERSION` routine to extract the version from a specified MISR product file and print the result. ```IDL ;; ;; Set up input parameters ;; file = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' status = MTK_FILE_VERSION( file, version ) ;; ;; Output... ;; print, 'file : ', file print, '=================================================' print, 'FILE VERSION : ',version ``` -------------------------------- ### Example Usage of MTK_CREATE_GEOGRID in IDL Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_create_geogrid.html Demonstrates how to call the MTK_CREATE_GEOGRID function in IDL. This example sets up input parameters for a specific geographic area and then executes the function, followed by printing information about the resulting latitude and longitude buffers. ```IDL ;; ;; Set up input parameters ;; ulc_lat_dd = 40 ulc_lon_dd = -120.0 lrc_lat_dd = 30 lrc_lon_dd = -110.0 lat_cellsize_dd = 0.25 lon_cellsize_dd = 0.25 ;; ;; The call ;; status = MTK_CREATE_GEOGRID( ulc_lat_dd, ulc_lon_dd, lrc_lat_dd, lrc_lon_dd, lat_cellsize_dd, lon_cellsize_dd , latbuf, lonbuf ) ;; ;; Output... ;; print, '=================================================' help, latbuf, lonbuf ``` -------------------------------- ### IDL Example: Converting Packed DMS to Degrees, Minutes, Seconds Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_dms_to_deg_min_sec.html Demonstrates how to use the MTK_DMS_TO_DEG_MIN_SEC function in IDL, showing input setup, function call, and printing of the resulting degrees, minutes, and seconds. ```IDL ;; ;; Set up input parameters ;; packed_dms = 65033011.1 status = MTK_DMS_TO_DEG_MIN_SEC( packed_dms, deg, minutes, seconds ) ;; ;; Output... ;; print, 'packed dms : ', packed_dms print, '=================================================' print, 'DEGREES : ',deg print, 'MINUTES : ',minutes print, 'SECONDS : ',seconds ``` -------------------------------- ### IDL Example: Convert SOM X/Y to Map Line/Sample Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_somxy_to_ls.html Demonstrates how to use MTK_SOMXY_TO_LS in IDL to convert Space Oblique Mercator (SOM) coordinates to map line and sample. The example includes steps for setting up input parameters like filename, grid, field, SOM coordinates, and block range, followed by calls to MTK_FILE_TO_PATH, MTK_SETREGION_BY_PATH_BLOCKRANGE, MTK_READDATA, and finally MTK_SOMXY_TO_LS. The script then prints all input parameters and the resulting line and sample. ```IDL ;; ;; Set up input parameters ;; filename = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' gridname = 'GreenBand' fieldname = 'Green Radiance/RDQI' somx = 8783500.0 somy = 608300.0 start_block = 10 end_block = 15 status = MTK_FILE_TO_PATH( filename, path ) status = MTK_SETREGION_BY_PATH_BLOCKRANGE( path, start_block, end_block, region) status = MTK_READDATA( filename, gridname, fieldname, region, databuf, mapinfo ) status = MTK_SOMXY_TO_LS( mapinfo, somx, somy, line, sample ) ;; ;; Output... ;; print, 'file name : ', filename print, 'grid : ', gridname print, 'field : ', fieldname print, 'start block : ', start_block print, 'end block : ', end_block print, 'som x : ', somx print, 'som y : ', somy print, '=================================================' print, 'LINE : ',line print, 'SAMPLE : ',sample ``` -------------------------------- ### IDL Example: Using MTK_RESAMPLE_CUBICCONVOLUTION Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_resample_cubicconvolution.html Illustrates an IDL implementation example for the MTK_RESAMPLE_CUBICCONVOLUTION routine. This snippet demonstrates setting up dummy input data, invoking the resampling function, and then printing diagnostic information about the output, including the count of valid masked elements and array dimensions. ```IDL ;; ;; Set up input parameters ;; source = RANDOMU(seed, 40, 60) source_mask = byte(REPLICATE(1,40,60)) line = RANDOMU(seed, 40, 60) * 400 sample = RANDOMU(seed, 40, 60) * 600 a = -0.5 ;; ;; The call ;; status = MTK_RESAMPLE_CUBICCONVOLUTION( source, source_mask, line, sample, a, resampled, resampled_mask ) ;; ;; Output... ;; print, '=================================================' a = WHERE(resampled_mask EQ 1, mask_count) print, mask_count help, resampled, resampled_mask ``` -------------------------------- ### IDL Example: Using MTK_LINEAR_REGRESSION_CALC for Linear Regression Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_linear_regression_calc.html Illustrates the practical application of the MTK_LINEAR_REGRESSION_CALC function in IDL. This example demonstrates how to initialize input arrays, call the linear regression routine, and print the resulting 'a', 'b', and 'corr' values to the console. ```IDL ;; ;; Set up input parameters ;; num = 4 x = [1,5,7,8] y = [12,14,19,21] y_sigma = [0.1, 0.2, 0.2, 0.3] ;; ;; The call ;; status = MTK_LINEAR_REGRESSION_CALC( num, x, y, y_sigma, a, b, corr ) ;; ;; Output... ;; print, '=================================================' print, a, b, corr ``` -------------------------------- ### Example: Using MTK_FIND_FILELIST to Find MISR Data Files in IDL Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_find_filelist.html This example demonstrates how to set up input parameters and call the `MTK_FIND_FILELIST` function in IDL to locate specific MISR data files, then prints the results. ```IDL ;; ;; Set up input parameters ;; search_dir = '../Mtk_testdata/in/' product = 'GRP_ELLIPSOID_GM' camera = '.*' path = '037' orbit = '029058' version = 'F03_0024' status = MTK_FIND_FILELIST( search_dir, product, camera, path, orbit, version, cnt, files ) ;; ;; Output... ;; print, 'search directory : ', search_dir print, 'product : ', product print, 'camera : ', camera print, 'path : ', path print, 'orbit : ', orbit print, 'version : ', version print, '=================================================' FOR i =0,cnt-1 DO $ PRINT, 'FILE #'+STRTRIM(i+1,2)+ $ ' : '+files[i] ``` -------------------------------- ### Create MtkRegion Object (Path and Block Range) Source: https://github.com/nasa/misr-toolkit/blob/master/doc/pymtk/mtkregion.html Illustrates how to construct a `MtkRegion` object by specifying a path number and a start and end block range. ```Python r = MtkRegion(37, 50, 60) ``` -------------------------------- ### IDL Example: Convert Line/Sample to SOM X/Y using MTK_LS_TO_SOMXY Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_ls_to_somxy.html This IDL example demonstrates the usage of the MTK_LS_TO_SOMXY function. It shows how to set up input parameters, read data using other MTK functions (MTK_FILE_TO_PATH, MTK_SETREGION_BY_PATH_BLOCKRANGE, MTK_READDATA), and then apply MTK_LS_TO_SOMXY to convert line and sample coordinates to SOM X and Y, finally printing the results. ```IDL ;; ;; Set up input parameters ;; filename = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' gridname = 'GreenBand' fieldname = 'Green Radiance/RDQI' line = 50.0 sample = 25.0 start_block = 10 end_block = 15 status = MTK_FILE_TO_PATH( filename, path ) status = MTK_SETREGION_BY_PATH_BLOCKRANGE( path, start_block, end_block, region) status = MTK_READDATA( filename, gridname, fieldname, region, databuf, mapinfo ) status = MTK_LS_TO_SOMXY( mapinfo, line, sample, somx, somy ) ;; ;; Output... ;; print, 'file name : ', filename print, 'grid : ', gridname print, 'field : ', fieldname print, 'start block : ', start_block print, 'end block : ', end_block print, 'line : ', line print, 'sample : ', sample print, '=================================================' print, 'SOM X : ',somx print, 'SOM Y : ',somy ``` -------------------------------- ### MtkReadData Example: Subsetting by Path and Block Range Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Example demonstrating how to use MtkReadData to extract data from a MISR HDF file by specifying a path and a range of blocks (45 to 75) for a specific product. ```Shell MtkReadData --setregion-path-blockrange=37,45,75 --hdffilename=../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf --gridname=BlueBand --fieldname="Blue Radiance/RDQI" --binfilename=out.bin ``` -------------------------------- ### Snap MtkRegion to MISR Grid Source: https://github.com/nasa/misr-toolkit/blob/master/doc/pymtk/mtkregion.html Example of using the `snap_to_grid` method on an `MtkRegion` object to align it with a MISR grid based on a given path and resolution. ```Python r.snap_to_grid(37, 1100) ``` -------------------------------- ### IDL Example: Retrieving MISR Orbits by Path and Time Range Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_path_timerange_to_orbitlist.html This IDL example demonstrates how to use the MTK_PATH_TIMERANGE_TO_ORBITLIST routine to find all MISR orbits within a specified path and time period, and then prints the results. ```IDL ;; ;; Set up input parameters ;; path = 37 start_time = '2002-02-02T02:00:00Z' ;YYYY-MM-DDThh:mm:ssZ end_time = '2002-05-02T02:00:00Z' ;YYYY-MM-DDThh:mm:ssZ status = MTK_PATH_TIMERANGE_TO_ORBITLIST( path, start_time, end_time, orbit_cnt, orbit_list ) ;; ;; Output... ;; print, 'path : ', path print, 'starting time : ', start_time print, 'ending time : ', end_time print, '=================================================' print, '--- ORBIT LIST ---' FOR i=0,orbit_cnt-1 DO print, orbit_list[i] ``` -------------------------------- ### IDL Example: Reading MISR Data with MTK_READRAW Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_readraw.html This IDL example demonstrates how to set up input parameters, define a geographic region using `MTK_SETREGION_BY_LATLON_EXTENT`, and then use `MTK_READRAW` to read raw MISR data. It also shows how to print the returned data buffer and map information structure for verification. ```IDL ;; ;; Set up input parameters ;; filename = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' gridname = 'RedBand' fieldname = 'Red Radiance/RDQI' lat = 66.0 lon = -89.0 lat_extent = 1.5 lon_extent = 1.0 status = MTK_SETREGION_BY_LATLON_EXTENT( lat, lon, lat_extent, lon_extent, "degrees", region ) status = MTK_READRAW( filename, gridname, fieldname, region, databuf, mapinfo ) ;; ;; Output... ;; print, 'file : ', filename print, 'grid : ', gridname print, 'field : ', fieldname print, '=================================================' help, databuf help,/struct, mapinfo ``` -------------------------------- ### IDL Example: Retrieve Coremetadata with MTK_FILE_COREMETADATA_GET Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_file_coremetadata_get.html An IDL example demonstrating how to use the MTK_FILE_COREMETADATA_GET routine to extract the 'LOCALVERSIONID' coremetadata parameter from a specified MISR HDF file and print the result. ```IDL ;; ;; Set up input parameters ;; file = '../Mtk_testdata/in/MISR_AM1_AS_LAND_P037_O029058_F06_0017.hdf' paramname = 'LOCALVERSIONID' status = MTK_FILE_COREMETADATA_GET( file, paramname, paramval ) ;; ;; Output... ;; print, 'file : ', file print, 'parameter name : ', paramname print, '=================================================' print, 'parameter value : ', paramval ``` -------------------------------- ### IDL Example: Retrieving MISR File Block Metadata Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_file_block_meta_list.html Illustrates the practical application of MTK_FILE_BLOCK_META_LIST in IDL. This example sets a sample MISR product filename, calls the function to retrieve block metadata, and then prints the filename, the count of block metadata, and the list of metadata. The expected output shows 3 block metadata entries: 'PerBlockMetadataCommon', 'PerBlockMetadataRad', and 'PerBlockMetadataTime'. ```IDL ;; Set up input parameters filename = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' status = MTK_FILE_BLOCK_META_LIST( filename, nblockmeta, blockmetalist ) ;; Output... print, 'Filename : ', filename print, '=================================================' print, 'Number block metadata : ', nblockmeta print, 'Block metadata list : ', blockmetalist ``` -------------------------------- ### Python Example: Resampling Regression Coefficients with MISR Toolkit Source: https://github.com/nasa/misr-toolkit/blob/master/doc/pymtk/mtkregression.html This Python example demonstrates how to use the MISR Toolkit to read data from an HDF file, prepare input arrays (data, masks, sigma), calculate initial regression coefficients using `coeff_calc`, and then resample these coefficients to a new target map information using `resample_reg_coeff`. ```Python r = MtkRegion(37, 50, 60) m = MtkFile('../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf') g1 = m.grid('BlueBand') f1 = g1.field('Blue Radiance') data1 = f1.read(r).data() mask1 = numpy.ones((data1.shape[0],data1.shape[1]), dtype= numpy.uint8) g2 = m.grid('GreenBand') f2 = g2.field('Green Radiance') data2 = f2.read(r).data() sigma2 = numpy.tile((numpy.linspace(0.1,0.6,data2.shape[0])), (data2.shape[1],1)).transpose() sigma2 = sigma2.astype(numpy.float32) mask2 = numpy.ones((data2.shape[0],data2.shape[1]), dtype= numpy.uint8) mapinfo = f2.read(r).mapinfo() sizefactor = 2 regr_coeff, regr_mapinfo = regr.coeff_calc(data1, mask1, data2, sigma2, mask2, sizefactor, mapinfo) target_map_info = MtkRegion(37, 50, 60).snap_to_grid(37, 1100) regr.resample_reg_coeff(regr_coeff, regr_mapinfo, target_map_info) ``` -------------------------------- ### MtkFileGridToResolution Utility API Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html API documentation for MtkFileGridToResolution, a utility to get the resolution of a specific grid within a MISR product file. ```APIDOC MtkFileGridToResolution: Usage: ./MtkFileGridToResolution ``` -------------------------------- ### IDL Example: Extracting MISR Path from File Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_file_to_path.html Illustrates how to call the MTK_FILE_TO_PATH routine in IDL. The example sets an input file path, calls the function, and then prints the extracted MISR path number along with the input file name. ```IDL ;; ;; Set up input parameters ;; file = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' status = MTK_FILE_TO_PATH( file, path ) ;; ;; Output... ;; print, 'file : ', file print, '=================================================' print, 'PATH : ',path ``` -------------------------------- ### Get Time Range for a Specific Orbit Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Example of MtkOrbitToTimeRange to find the start and end times for a given orbit number. ```Shell MtkOrbitToTimeRange 24372 ``` -------------------------------- ### Build MisrToolkit_bundled.lib with lib.exe Source: https://github.com/nasa/misr-toolkit/blob/master/win64/MisrToolkit/x64/Release/build_bundled.txt This snippet demonstrates the command-line steps required to build the `MisrToolkit_bundled.lib` library. It involves navigating to the correct directory and then using `lib.exe` to link the MisrToolkit with its various HDF, NetCDF, and other utility libraries. ```Batch cd C:\Mtk\win64\MisrToolkit\x64\Release ``` ```Batch lib.exe /OUT:MisrToolkit_bundled.lib /LIBPATH:"C:\Mtk\win64\HDF_4.2.14\lib" /LIBPATH:"C:\Mtk\win64\hdfeos_2.19\lib" /LIBPATH:"C:\Mtk\win64\HDF5_1.8.21\lib" /LIBPATH:"C:\Mtk\win64\netcdf_4.7.4\lib" /LIBPATH:"C:\Mtk\win64\MisrToolkit\x64\Release" /LIBPATH:"C:\Mtk\win64\tre_0.8.0\lib" sleep.lib ws2_32.lib tre.lib libxdr.lib libjpeg.lib libszip.lib gctp.lib libhdf.lib libmfhdf.lib hdfeos.lib libzlib.lib libhdf5.lib libhdf5_hl.lib netcdf.lib MisrToolkit.lib ``` -------------------------------- ### Get Start and End Times for MISR Orbit in IDL Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_orbit_to_timerange.html This IDL example demonstrates how to use the MTK_ORBIT_TO_TIMERANGE routine to retrieve the start and end times for a specified MISR orbit number. It initializes an orbit number, calls the function, and then prints the returned start and end times to the console. ```IDL ;; ;; Set up input parameters ;; orbit = 32467 status = MTK_ORBIT_TO_TIMERANGE( orbit, start_time, end_time ) ;; ;; Output... ;; print, 'orbit : ', orbit print, '=================================================' print, 'start time : ', start_time print, 'end time : ', end_time ``` -------------------------------- ### IDL Example: Reading a Single Block of MISR Data Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_readblock.html This example demonstrates how to use MTK_READBLOCK to read a single block of data from a MISR product file using specified filename, gridname, fieldname, and block number. It also shows how to print the input parameters and inspect the output data buffer's type and dimensions. ```IDL ;; ;; Set up input parameters ;; filename = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' gridname = 'RedBand' fieldname = 'Red Radiance/RDQI' blocknum = 40 status = MTK_READBLOCK( filename, gridname, fieldname, blocknum, databuf ) ;; ;; Output... ;; print, 'file : ', filename print, 'grid : ', gridname print, 'field : ', fieldname print, 'block number : ', blocknum print, '=================================================' help, databuf ``` -------------------------------- ### Example: Calculate Linear Regression using MtkRegression Source: https://github.com/nasa/misr-toolkit/blob/master/doc/pymtk/mtkregression.html Demonstrates how to use the linear_regression_calc method to fit a linear model to sample data, including x, y, and y-sigma values. ```Python x = numpy.linspace(2,12,num = 5) y = numpy.linspace(4,24,num = 5) ysigma = numpy.linspace(0.1,0.6,num = 5) regr.linear_regression_calc(x,y,ysigma) (array([ 0.00000000e+000, -2.32035723e+077, 2.15126649e-314, 1.06717989e-287, 3.38503263e+125]), array([ 2.00000000e+000, -2.68679011e+154, 2.15168741e-314, 2.15170772e-314, 2.32035723e+077]), array([ 1.00000000e+000, 3.11109040e+231, 2.15175217e-314, 6.94154000e-310, -3.11109040e+231])) ``` -------------------------------- ### Example: Get MISR File Type Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Example command to use `MtkFileType` to identify the type of a specified MISR HDF file. ```Shell MtkFileType --hdffilename=../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf ``` -------------------------------- ### Initialize MtkMapInfo Object Source: https://github.com/nasa/misr-toolkit/blob/master/doc/pymtk/mtkmapinfo.html Demonstrates how to initialize an `MtkMapInfo` object by snapping an `MtkRegion` to a grid, which is a prerequisite for using its methods and properties. ```Python map_info = MtkRegion(37, 35, 36).snap_to_grid(37, 1100) ``` -------------------------------- ### MtkReadBlockRange Example: Reading Specific Block Range Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Example demonstrating how to use MtkReadBlockRange to extract data from a MISR HDF file by specifying a start block (35) and an end block (40). ```Shell MtkReadBlockRange --hdffilename=../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf --gridname=BlueBand --fieldname="Blue Radiance/RDQI" --startblock=35 --endblock=40 --binfilename=out.bin ``` -------------------------------- ### IDL Example: Calculating Pixel Time with MTK_PIXEL_TIME Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_pixel_time.html This IDL example demonstrates the full workflow for using MTK_PIXEL_TIME. It involves reading time metadata from two different L1B2 HDF files, converting block/line/sample coordinates to SOM X/Y using MTK_BLS_TO_SOMXY, and then calling MTK_PIXEL_TIME for each camera to obtain the pixel date/time. ```IDL ;; ;; Set up input parameters ;; L1B2_filename_aa = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AA_F03_0024.hdf' L1B2_filename_an = '../Mtk_testdata/in/MISR_AM1_GRP_ELLIPSOID_GM_P037_O029058_AN_F03_0024.hdf' path = 37 resolution = 275 block = 50 line = 105 sample = 650 status = MTK_TIME_META_READ( L1B2_filename_aa, timemeta_aa ) status = MTK_TIME_META_READ( L1B2_filename_an, timemeta_an ) status = MTK_BLS_TO_SOMXY( path, resolution, block, line, sample, somx, somy ) status = MTK_PIXEL_TIME( timemeta_aa, somx, somy, pixel_datetime_aa ) status = MTK_PIXEL_TIME( timemeta_an, somx, somy, pixel_datetime_an ) ;; ;; Output... ;; print, 'L1B2_filename_aa : ', L1B2_filename_aa print, 'L1B2_filename_an : ', L1B2_filename_an print, 'Path : ', path print, 'Resolution : ', resolution print, 'Block : ', block print, 'Line : ', line print, 'Sample : ', sample print, '=================================================' print, 'Pixel Date/Time AA : ', pixel_datetime_aa print, 'Pixel Date/Time AN : ', pixel_datetime_an ``` -------------------------------- ### Initialize HdfFile Instance (C++ and APIDOC) Source: https://github.com/nasa/misr-toolkit/blob/master/wrappers/ruby/src/doc/classes/HdfFile.html The `new` method is a public class method used to instantiate an `HdfFile` object by opening a specified HDF-EOS filename. It takes the filename as a string argument and returns a new `HdfFile` instance. The C++ implementation handles file opening and error management. ```APIDOC HdfFile.new(filename) -> HdfFile Description: Open the given filename. Parameters: filename: The path to the HDF-EOS file to open. Returns: An instance of HdfFile. ``` ```C++ /* call-seq: * HdfFile.new(filename) -> HdfFile * * Open the given filename. * */ static VALUE hdf_init(VALUE self, VALUE name_obj) { try { HdfFile* h; Data_Get_Struct(self, HdfFile, h); h->open(RSTRING(StringValue(name_obj))->ptr); } catch (const std::exception& e) { rb_raise(rb_eRuntimeError, "%s", e.what()); } } ``` -------------------------------- ### List Orbits for Path and Time Range Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Example of MtkPathTimeRangeToOrbitList to find orbits for a specific path within a given time window. ```Shell MtkPathTimeRangeToOrbitList --path=78 --start=2002-02-02T02:00:00Z --end=2002-05-02T02:00:00Z ``` -------------------------------- ### MTK_PATH_TO_PROJPARAM API Reference Source: https://github.com/nasa/misr-toolkit/blob/master/doc/IDL_HTML_DOCS/mtk_path_to_projparam.html API documentation for the MTK_PATH_TO_PROJPARAM routine, detailing its input parameters, return values, and overall signature. ```APIDOC MTK_PATH_TO_PROJPARAM(path, res, proj_params) Description: Returns projection parameters for the given path and resolution. Parameters: path: MISR path res: resolution in meters Returns: status: 0 on success; otherwise failure proj_params: IDL structure containing projection parameters ``` -------------------------------- ### Convert Region to Block Range using Path and Block Range Source: https://github.com/nasa/misr-toolkit/blob/master/doc/cmdtable.html Example of MtkRegionPathToBlockRange using a predefined path and block range. ```Shell MtkRegionPathToBlockRange --path=37 --setregion-path-blockrange=37,45,75 ``` -------------------------------- ### C Example: Initializing and Setting Region with MTKt_MapInfo Source: https://github.com/nasa/misr-toolkit/blob/master/doc/Mtk_struct.html Illustrates the initialization of MTKt_MapInfo and related structures (MTKt_Region, MTKt_DataBuffer) and demonstrates how to set a region of interest using MtkSetRegionByLatLonExtent. This function populates the MTKt_MapInfo structure with relevant geographic and projection details for subsequent map queries. ```C #include "MisrToolkit.h" MTKt_status status; MTKt_Region region = MTK_REGION_INIT; MTKt_DataBuffer buf = MTKT_DATABUFFER_INIT; MTKt_MapInfo mapinfo = MTKT_MAPINFO_INIT; status = MtkSetRegionByLatLonExtent(32.0, -108.0, 120.0, 360.0, "km", region); ```