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 */ 028package edu.wisc.ssec.mcidasv.data.hydra; 029 030import org.slf4j.Logger; 031import org.slf4j.LoggerFactory; 032import visad.FlatField; 033import java.util.HashMap; 034import java.util.Map; 035 036/** 037 * 038 * 039 */ 040public class ReflSolzenCorr extends RangeProcessor { 041 042 private static final Logger logger = 043 LoggerFactory.getLogger(ReflSolzenCorr.class); 044 045 ArrayAdapter solzenAdapter; 046 047 048 public ReflSolzenCorr(NetCDFFile reader, Map<String, Object> metadata, ArrayAdapter solzenAdapter) throws Exception { 049 super(reader, metadata); 050 this.solzenAdapter = solzenAdapter; 051 } 052 053 public ReflSolzenCorr(NetCDFFile reader, Map<String, Object> metadata) throws Exception { 054 super(reader, metadata); 055 } 056 057 /** 058 * super returns uncorrected reflectance. 059 * 060 */ 061 public float[] processRange(short[] values, Map<String, double[]> subset) { 062 float[] refls = super.processRange(values, subset); 063 float[] solzen = null; 064 065 try { 066 solzen = solzenAdapter.getData(subset).getFloats()[0]; 067 } catch (Exception e) { 068 logger.error("problem getting data", e); 069 } 070 for (int k=0; k<refls.length; k++) { 071 float refl = refls[k]; 072 float solz = solzen[k]; 073 if (solz < 88f) { 074 refls[k] = refl/((float)Math.cos((Math.PI/180.0)*solz)); 075 } 076 } 077 078 return refls; 079 } 080}