001/*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2024
005 * Space Science and Engineering Center (SSEC)
006 * University of Wisconsin - Madison
007 * 1225 W. Dayton Street, Madison, WI 53706, USA
008 * https://www.ssec.wisc.edu/mcidas/
009 * 
010 * All Rights Reserved
011 * 
012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013 * some McIDAS-V source code is based on IDV and VisAD source code.  
014 * 
015 * McIDAS-V is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU Lesser Public License as published by
017 * the Free Software Foundation; either version 3 of the License, or
018 * (at your option) any later version.
019 * 
020 * McIDAS-V is distributed in the hope that it will be useful,
021 * but WITHOUT ANY WARRANTY; without even the implied warranty of
022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023 * GNU Lesser Public License for more details.
024 * 
025 * You should have received a copy of the GNU Lesser Public License
026 * along with this program.  If not, see https://www.gnu.org/licenses/.
027 */
028
029package edu.wisc.ssec.mcidasv.data.hydra;
030
031import visad.Gridded2DSet;
032import visad.RealTupleType;
033
034public class IASI_L1C_LonLatNavigation extends SwathNavigation  {
035
036  public IASI_L1C_LonLatNavigation(SwathAdapter swathAdapter) throws Exception {
037    super(swathAdapter);
038  }
039
040  Gridded2DSet createInterpSet() throws Exception {
041    float scale = 1E-06f;
042
043    int[] new_geo_start = new int[2]; 
044    int[] new_geo_count = new int[2]; 
045    int[] new_geo_stride = new int[2]; 
046
047    new_geo_start[geo_xtrack_idx] = 0;
048    new_geo_count[geo_xtrack_idx] = 60*2;
049    new_geo_stride[geo_xtrack_idx] = 1;
050    new_geo_start[geo_track_idx] = 0;
051    new_geo_count[geo_track_idx] = geo_count[geo_track_idx]/2;
052    new_geo_stride[geo_track_idx] = 1;
053
054    int[] lonValues = reader.getIntArray(lon_array_name, new_geo_start, new_geo_count, new_geo_stride);
055    int[] latValues = reader.getIntArray(lat_array_name, new_geo_start, new_geo_count, new_geo_stride);
056
057    float[] lons = new float[lonValues.length];
058    float[] lats = new float[latValues.length];
059
060    for (int k=0; k<lons.length; k++) {
061      lons[k] = ((float)lonValues[k])*scale;
062      lats[k] = ((float)latValues[k])*scale;
063    }
064
065    lons = IASI_L1C_Utility.psuedoScanReorder2(lons, 60, geo_count[0]);
066    lats = IASI_L1C_Utility.psuedoScanReorder2(lats, 60, geo_count[0]);
067                                                                                                                                             
068    Gridded2DSet gset = new Gridded2DSet(RealTupleType.SpatialEarth2DTuple,
069                   new float[][] {lons, lats},
070                        geo_count[idx_order[0]], geo_count[idx_order[1]],
071                            null, null, null, false, false);
072    return gset;
073  }
074}