/* * Copyright (C) 1998 by Southwest Research Institute (SwRI) * * All rights reserved under U.S. Copyright Law and International Conventions. * * The development of this Software was supported by contracts NAG5-3148, * NAG5-6855, NAS8-36840, NAG5-2323, and NAG5-7043 issued on behalf of * the United States Government by its National Aeronautics and Space * Administration. Southwest Research Institute grants to the Government, * and others acting on its behalf, a paid-up nonexclusive, irrevocable, * worldwide license to reproduce, prepare derivative works, and perform * publicly and display publicly, by or on behalf of the Government. * Other than those rights granted to the United States Government, no part * of this Software may be reproduced in any form or by any means, electronic * or mechanical, including photocopying, without permission in writing from * Southwest Research Institute. All inquiries should be addressed to: * * Director of Contracts * Southwest Research Institute * P. O. Drawer 28510 * San Antonio, Texas 78228-0510 * * * Use of this Software is governed by the terms of the end user license * agreement, if any, which accompanies or is included with the Software * (the "License Agreement"). An end user will be unable to install any * Software that is accompanied by or includes a License Agreement, unless * the end user first agrees to the terms of the License Agreement. Except * as set forth in the applicable License Agreement, any further copying, * reproduction or distribution of this Software is expressly prohibited. * Installation assistance, product support and maintenance, if any, of the * Software is available from SwRI and/or the Third Party Providers, as the * case may be. * * Disclaimer of Warranty * * SOFTWARE IS WARRANTED, IF AT ALL, IN ACCORDANCE WITH THESE TERMS OF THE * LICENSE AGREEMENT. UNLESS OTHERWISE EXPLICITLY STATED, THIS SOFTWARE IS * PROVIDED "AS IS", IS EXPERIMENTAL, AND IS FOR NON-COMMERCIAL USE ONLY, * AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT * SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. * * Limitation of Liability * * SwRI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED AS A RESULT OF USING, * MODIFYING, CONTRIBUTING, COPYING, DISTRIBUTING, OR DOWNLOADING THIS * SOFTWARE. IN NO EVENT SHALL SwRI BE LIABLE FOR ANY INDIRECT, PUNITIVE, * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGE (INCLUDING LOSS OF BUSINESS, * REVENUE, PROFITS, USE, DATA OR OTHER ECONOMIC ADVANTAGE) HOWEVER IT ARISES, * WHETHER FOR BREACH OF IN TORT, EVEN IF SwRI HAS BEEN PREVIOUSLY ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. YOU HAVE SOLE RESPONSIBILITY FOR ADEQUATE * PROTECTION AND BACKUP OF DATA AND/OR EQUIPMENT USED IN CONNECTION WITH THE * SOFTWARE AND WILL NOT MAKE A CLAIM AGAINST SwRI FOR LOST DATA, RE-RUN TIME, * INACCURATE OUTPUT, WORK DELAYS OR LOST PROFITS RESULTING FROM THE USE OF * THIS SOFTWARE. YOU AGREE TO HOLD SwRI HARMLESS FROM, AND YOU COVENANT NOT * TO SUE SwRI FOR, ANY CLAIMS BASED ON USING THE SOFTWARE. * * Local Laws: Export Control * * You acknowledge and agree this Software is subject to the U.S. Export * Administration Laws and Regulations. Diversion of such Software contrary * to U.S. law is prohibited. You agree that none of the Software, nor any * direct product therefrom, is being or will be acquired for, shipped, * transferred, or reexported, directly or indirectly, to proscribed or * embargoed countries or their nationals, nor be used for nuclear activities, * chemical biological weapons, or missile projects unless authorized by U.S. * Government. Proscribed countries are set forth in the U.S. Export * Administration Regulations. Countries subject to U.S embargo are: Cuba, * Iran, Iraq, Libya, North Korea, Syria, and the Sudan. This list is subject * to change without further notice from SwRI, and you must comply with the * list as it exists in fact. You certify that you are not on the U.S. * Department of Commerce's Denied Persons List or affiliated lists or on the * U.S. Department of Treasury's Specially Designated Nationals List. You agree * to comply strictly with all U.S. export laws and assume sole responsibilities * for obtaining licenses to export or reexport as may be required. * * General * * These Terms represent the entire understanding relating to the use of the * Software and prevail over any prior or contemporaneous, conflicting or * additional, communications. SwRI can revise these Terms at any time * without notice by updating this posting. * * Trademarks * * The SwRI logo is a trademark of SwRI in the United States and other countries. * */ #ident "@(#) read_drec_data.c 1.7 05/08/19 SwRI" #include "ret_codes.h" #include "gen_defs.h" #include "libbase_idfs.h" /**************************************************************************** * * * IR_READ_DREC_DATA_VALUES SUBROUTINE * * * * DESCRIPTION * * This routine is called when the requested sensor has been found among * * the sensors returned for the current data record. The data values and * * the calibration values for the sensor are returned, along with any * * angular information. * * * * INPUT VARIABLES * * void *idf_data_ptr ptr to memory location for the structure * * that holds returned data values (read_drec)* * SDDAS_SHORT sen the sensor for which data is requested * * SDDAS_CHAR fwd flag that indicates when to advance to the * * time sample * * SDDAS_CHAR full_swp request 1 or all values in sensor set be * * returned (for scalar parameters only) * * SDDAS_LONG sen_index index value that tells the position of the * * sensor within the sensors returned * * * * USAGE * * x = ir_read_drec_data_values (idf_data_ptr, sen, fwd, full_swp, * * sen_index) * * * * NECESSARY SUBPROGRAMS * * ir_fill_data_array () fills the data structure with the data for * * the requested sensor * * ir_fill_cal_array_byte () fills in the data structure with the cal. * * data for the requested sensor for virtual * * instruments with TDW_LEN >= 8 * * ir_fill_cal_array_bit () fills in the data structure with the cal. * * data for the requested sensor for virtual * * instruments with TDW_LEN < 8 * * ir_fill_angle_array () fills the data structure with the starting * * and ending azimuthal angles for requested * * sensor * * ir_idfs_pitch_angles () fills the data structure with the computed * * pitch angles derived from the IDFS source * * ir_constant_pitch_angles() fills the data structure with the pitch * * angle constants defined in the VIDF file * * ir_idfs_potential_values() fills the data structure with the computed * * spacecraft potential values derived from * * the IDFS source * * ir_constant_spacecraft_potential() fills the data structure with the * * constant spacecraft potential data value * * ir_idfs_euler_angles () fills the data structure with the computed * * euler angles derived from the IDFS source * * ir_constant_euler_angles() fills the data structure with the euler * * angle constants defined in the VIDF file * * ir_idfs_celestial_position_angles () fills the data structure with * * the computed celestial position angles * * derived from the IDFS source * * ir_constant_celestial_position_angles() fills the data structure with * * the celestial position constants defined * * in the VIDF file * * ir_idfs_background_data() fills the data structure with the computed * * background values derived from the IDFS * * source * * ir_constant_background() fills the data structure with the * * constant background data value * * ir_compute_idfs_sweep_times() determines the time of each element in * * the sweep * * * * EXTERNAL VARIABLES * * struct general_info structure holding information concerning * * ginfo the experiment that is being processed * * * * INTERNAL VARIABLES * * struct idf_data *EXP_DATA structure that holds all of the currently * * returned data values to be processed * * struct experiment_info a pointer to the structure that holds * * *ex specific experiment information * * struct ptr_rec *ptr a pointer to the structure which holds all * * pointers to the header and data for the * * experiment of interest * * struct pitch_info a pointer to the structure that holds pitch* * *pa_ptr angle information * * struct potential_info a pointer to the structure that holds * * *potential_ptr spacecraft potential information * * struct euler_info a pointer to the structure that holds euler* * *pmi_ptr angle information * * struct transformation_info *trans_ptr ptr to transformation structure* * struct celestial_info a pointer to the structure that holds * * *cp_ptr celestial position information * * struct background_info a pointer to the structure that holds * * *bkgd_ptr background information * * SDDAS_USHORT max_ele number of elements in the sweep * * SDDAS_USHORT n_sample number of samples returned for each sensor * * SDDAS_SHORT rval holds called routine status flags * * * * SUBSYSTEM * * Display Level * * * ***************************************************************************/ SDDAS_SHORT ir_read_drec_data_values (void *idf_data_ptr, SDDAS_SHORT sen, SDDAS_CHAR fwd, SDDAS_CHAR full_swp, SDDAS_LONG sen_index) { extern struct general_info ginfo; struct idf_data *EXP_DATA; struct experiment_info *ex; struct ptr_rec *ptr; struct pitch_info *pa_ptr; struct potential_info *potential_ptr; struct euler_info *pmi_ptr; struct transformation_info *trans_ptr; struct celestial_info *cp_ptr; struct background_info *bkgd_ptr; SDDAS_USHORT max_ele, n_sample; SDDAS_SHORT rval; /*************************************************************************/ /* Retrieve the sensor data and any calibration data for the requested */ /* sensor. */ /*************************************************************************/ EXP_DATA = (struct idf_data *) idf_data_ptr; trans_ptr = EXP_DATA->idfs_transformation; ex = ginfo.expt; ptr = ex->info_ptr; EXP_DATA->filled_data = 1; rval = ir_fill_data_array (sen_index, full_swp, idf_data_ptr); if (rval != ALL_OKAY) return (rval); if (ptr->num_all_swp_cal != 0 || ptr->num_all_sen_cal != 0 || ptr->num_swp_cal != 0 || ptr->num_sen_cal != 0) { if (ex->tdw_len >= 8) ir_fill_cal_array_byte (sen_index, idf_data_ptr); else ir_fill_cal_array_bit (sen_index, idf_data_ptr); } ex->num_sample = EXP_DATA->num_sample; /*************************************************************************/ /* Retrieve angular information. */ /*************************************************************************/ rval = ir_fill_angle_array (full_swp, sen, idf_data_ptr); if (rval != ALL_OKAY) return (rval); EXP_DATA->start_theta = *(ex->constants + (START_THETA_OFF * ex->num_sensor) + sen); EXP_DATA->stop_theta = *(ex->constants + (STOP_THETA_OFF * ex->num_sensor) + sen); /****************************************************************************/ /* Compute the time per step values IF other data need the times. */ /****************************************************************************/ if (ex->swp_times.pa_times || ex->swp_times.pot_times || ex->swp_times.euler_times || ex->swp_times.celestial_times || ex->swp_times.background_times) { if (ex->swp_times.get_times) { ex->swp_times.get_times = 0; n_sample = *ptr->hdr_fmt1_ptr->N_SAMPLE; max_ele = (ex->smp_id == 2 && !full_swp) ? 1 : n_sample - ptr->time_row; rval = ir_compute_idfs_sweep_times (ex, ptr, max_ele, sen); if (rval != ALL_OKAY) return (rval); } } /**********************************************************************/ /* Calculate pitch angles. Check for non-null memory location in */ /* case pitch angle source also has pa_def set in the VIDF file. */ /**********************************************************************/ if (ex->pa_def && ex->bmem.base_pitch_info != NO_MEMORY) { if (ex->return_pitch_angles == sFalse) EXP_DATA->num_pitch = 0; else { pa_ptr = ex->pitch_angles; if (pa_ptr->pa_format == PA_COMPUTE) rval = ir_idfs_pitch_angles (fwd, full_swp, sen, idf_data_ptr); else rval = ir_constant_pitch_angles (full_swp, sen, idf_data_ptr); if (rval != ALL_OKAY) return (rval); } } /**********************************************************************/ /* Calculate spacecraft potential values. Check for non-null memory */ /* location in case spacecraft potential source also has */ /* potential_def set in the VIDF file. */ /**********************************************************************/ if (ex->potential_def && ex->bmem.base_potential_info != NO_MEMORY) { potential_ptr = ex->potential; if (potential_ptr->scpot_format == SCPOT_DSRC) rval = ir_idfs_potential_values (fwd, full_swp, sen, idf_data_ptr); else rval = ir_constant_spacecraft_potential (full_swp, idf_data_ptr); if (rval != ALL_OKAY) return (rval); } /**********************************************************************/ /* Calculate euler angles. Check for non-null memory location in */ /* case euler angle source also has euler_def set in the VIDF file. */ /**********************************************************************/ if (ex->euler_def && ex->bmem.base_euler_info != NO_MEMORY) { if (ex->return_euler_angles == sFalse) trans_ptr->num_euler = 0; else { pmi_ptr = ex->euler_angles; if (pmi_ptr->pmi_format == EULER_DSRC) rval = ir_idfs_euler_angles (fwd, full_swp, sen, idf_data_ptr); else rval = ir_constant_euler_angles (full_swp, sen, idf_data_ptr); if (rval != ALL_OKAY) return (rval); } } /**********************************************************************/ /* Calculate celestial position data. Check for non-null memory */ /* location in case celestial position source also has celestial_def */ /* set in the VIDF file. */ /**********************************************************************/ if (ex->celestial_def && ex->bmem.base_celestial_info != NO_MEMORY) { if (ex->return_celestial_pos == sFalse) trans_ptr->num_celestial = 0; else { cp_ptr = ex->celestial_position; if (cp_ptr->cp_format == CELESTIAL_DSRC) rval = ir_idfs_celestial_position_angles (fwd, full_swp, sen, idf_data_ptr); else rval = ir_constant_celestial_position_angles (full_swp, sen, idf_data_ptr); if (rval != ALL_OKAY) return (rval); } } /************************************************************************/ /* Calculate background values. Check for non-null memory location in */ /* case background source also has background_def set in the VIDF file.*/ /************************************************************************/ if (ex->background_def && ex->bmem.base_background_info != NO_MEMORY) { bkgd_ptr = ex->background; if (bkgd_ptr->background_format == BKGD_DSRC) rval = ir_idfs_background_data (fwd, full_swp, sen, idf_data_ptr); else rval = ir_constant_background (full_swp, sen, idf_data_ptr); if (rval != ALL_OKAY) return (rval); } if (fwd) ex->swp_times.get_times = 1; return (ALL_OKAY); }