/* * 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 "@(#) ret_phi.c 1.22 05/08/19 SwRI" #include #include "ret_codes.h" #include "gen_defs.h" #include "libtrec_idfs.h" /******************************************************************************* * * * RETURN_PHI_PTR SUBROUTINE * * * * DESCRIPTION * * This routine is called to return the phi bands and the data from the phi * * matrix for the sensor specified or for the theta bin specified if the * * sensor number is negative. The width of the phi bins was created using * * the information specified by the call to SET_BIN_INFO. If this routine * * was not called, an error code is returned. The data pointer returned * * points to the first element in the matrix, where the data is laid down by * * phi bin, with data_size elements being returned per phi bin. The data can * * be thought of as a 2-dimensional matrix, with data_size rows and num_phi * * columns. Before the data is returned, missing data bins are filled in if * * the user requested the bins to be filled. * * * * INPUT VARIABLES * * SDDAS_ULONG data_key key which uniquely identifies the data set * * being processed * * SDDAS_CHAR *exten filename extension of data to be used * * SDDAS_CHAR cyclic flag indicating if the data is cyclic * * SDDAS_CHAR bin_project flag indicating if the data is to be * * projected to the end of the bins * * SDDAS_USHORT vnum version number associated with this * * combination (allows for multiple opens) * * SDDAS_SHORT sensor the sensor for which data is requested * * or theta bin for which data is requested * * if the value is negative * * SDDAS_SHORT order the order of the fit (1, 2, 3, etc) * * SDDAS_SHORT unit_index value specifying which data level is to be * * processed * * SDDAS_SHORT *num_phi the number of phi bins being returned * * SDDAS_SHORT *data_size number of data values returned per phi bin * * SDDAS_FLOAT **ret_data pointer to the data being returned * * SDDAS_FLOAT tension the weighting of the data * * SDDAS_FLOAT **phi_bands pointer to the phi bin values * * SDDAS_LONG need_filled number of filled bins needed to perform the * * calculations to determine the missing bins * * SDDAS_CHAR cur_buf the buffer being processed (0 - 4) * * * * USAGE * * x = return_phi_ptrs (data_key, exten, vnum, sensor, &ret_data, cyclic, * * order, need_filled, tension, bin_project, * * unit_index, &num_phi, &phi_bands, &data_size, * * cur_buf) * * * * NECESSARY SUBPROGRAMS * * ir_locate_ex() determines if requested combination has * * already been pand points to the * * correct structure allocated for the combo * * ir_phi_bin_stat () sets/resets the bin status values for the * * normalization matrix which is associated * * with the 4D matrix (highest order is PHI) * * ir_fill_bin_elements () fills in missing bin elements * * abs() returns the absolute value of a number * * * * EXTERNAL VARIABLES * * struct general_info structure holding information concerning * * ginfo the experiment that is being processed * * * * INTERNAL VARIABLES * * reg struct experiment_info a pointer to the structure that holds * * *ex specific experiment information * * reg struct collapse_data pointer to the collapse_data structure * * *cptr being processed * * SDDAS_LONG off_theta_4d offset to get to the theta column being * * processed in the input data matrix * * SDDAS_LONG off_unit_4d offset to get to the beginning of the data * * matrix for the data level being processed * * SDDAS_SHORT ret_val holds called routine status flags * * SDDAS_SHORT num_theta number of theta bins * * SDDAS_SHORT which_theta offset to get to the theta bin of interest * * SDDAS_SHORT num_steps number of sweep bins * * char reset_called flag indicating if LOCATE_EX was called * * * * SUBSYSTEM * * Display Level * * * ******************************************************************************/ SDDAS_SHORT return_phi_ptrs (SDDAS_ULONG data_key, SDDAS_CHAR *exten, SDDAS_USHORT vnum, SDDAS_SHORT sensor, SDDAS_FLOAT **ret_data, SDDAS_CHAR cyclic, SDDAS_SHORT order, SDDAS_LONG need_filled, SDDAS_FLOAT tension, SDDAS_CHAR bin_project, SDDAS_SHORT unit_index, SDDAS_SHORT *num_phi, SDDAS_FLOAT **phi_bands, SDDAS_SHORT *data_size, SDDAS_CHAR cur_buf) { extern struct general_info ginfo; register struct experiment_info *ex; register struct collapse_data *cptr; SDDAS_LONG off_theta_4d, off_unit_4d; SDDAS_SHORT ret_val, num_theta, which_theta, num_steps; char reset_called; /**************************************************************************/ /* Check to see if the combination being processed has been processed */ /* before. If not, an error condition - probably didn't call FILE_OPEN. */ /**************************************************************************/ if (!ginfo.called_locate) { ret_val = ir_locate_ex (data_key, exten, vnum, 0); if (ret_val != ALL_OKAY) return (RET_PHI_NOT_FOUND); ginfo.called_locate = 1; reset_called = 1; } else reset_called = 0; ex = ginfo.expt; cptr = ex->collapse_ptr; if (ex->collapse_ptr == NO_MEMORY) { if (reset_called) ginfo.called_locate = 0; return (CPTR_RET_PHI); } /*************************************************************************/ /* If phi bins equals one, no phi matrix was collected. */ /*************************************************************************/ if (cptr->phi_bins == 1) return (NO_RET_PHI); /*************************************************************************/ /* If the missing data bins have not been filled in for the combo being */ /* processed, do so at this time. This is triggered once by the first */ /* plot using the specified combo. */ /*************************************************************************/ if (!cptr->filled_phi_matrix[(SDDAS_SHORT)cur_buf]) { ir_phi_bin_stat (0, cur_buf); ir_fill_bin_elements (cyclic, order, need_filled, tension, bin_project, cur_buf); } num_theta = (cptr->theta_bins <= 0) ? ex->num_sensor : cptr->theta_bins; num_steps = ex->bin_ptr->num_bins; if (sensor >= 0) which_theta = (cptr->theta_bins >= 0) ? *(cptr->sensor_bin + sensor) : sensor; else which_theta = (SDDAS_SHORT) (abs(sensor) - 1); /* CARRIE - could still be trouble */ *num_phi = cptr->phi_bins; *phi_bands = cptr->phi_bands; off_unit_4d = unit_index * (num_steps * num_theta * cptr->phi_bins); off_theta_4d = which_theta * num_steps * cptr->phi_bins; *ret_data = *(cptr->data_4d_ptr + cur_buf) + off_unit_4d + off_theta_4d; *data_size = ex->bin_ptr->num_bins; if (reset_called) ginfo.called_locate = 0; return (ALL_OKAY); }