/* * 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 "@(#) full_mode.c 1.15 05/08/19 SwRI" #include "ret_codes.h" #include "user_defs.h" #include "libtrec_idfs.h" /******************************************************************************* * * * IR_FULL_MODE_PIXELS SUBROUTINE * * * * DESCRIPTION * * This routine is called whenever the mode value being processed spans * * many pixels. This routine processes whole pixels; that is, 100% of the * * data value is utilized by the pixel range specified in the call. Instead * * of using a buffer per pixel, a start and stop pixel are given for each * * buffer. The data has already been converted into the appropriate units * * and is contained in an allocated scratch space. * * * * INPUT VARIABLES * * SDDAS_LONG pix_start starting pixel location which this data set * * is associated with * * SDDAS_LONG pix_end ending pixel location which this data set * * is associated with * * SDDAS_CHAR buf_num the buffer being processed (0 - 4) * * SDDAS_SHORT index indexing variable used to access the correct* * mode variables * * SDDAS_CHAR chk_buffers flag that indicates if there is a need to * * check if all buffers have been utilized * * SDDAS_SHORT *pix_yr, start time, in terms of the base time and * * *pix_day resolution, for the buffer's start pixel * * SDDAS_LONG *pix_sec, start time, in terms of the base time and * * *pix_nsec resolution, for the buffer's start pixel * * void *idf_data_ptr ptr to the memory location for the structure* * that holds returned data values (read_drec) * * * * USAGE * * x = ir_full_mode_pixels (pix_start, pix_end, buf_num, index, chk_buffers,* * &pix_yr, &pix_day, &pix_sec, &pix_nsec, * * idf_data_ptr) * * * * NECESSARY SUBPROGRAMS * * ir_get_mode_buffer_number() returns the next available buffer * * ir_mode_buffer () stores data into the buffer according to * * PPS using SAMP_INDEX values * * ir_next_pixel_time () determines the time of a pixel located * * x-many pixels away from current location * * adjust_time () corrects time elements if too many seconds * * (day crossing) or too many days (year * * crossing) * * * * EXTERNAL VARIABLES * * struct general_info ginfo structure that holds information concern- * * ing the experiment that is being processed * * SDDAS_FLOAT *ir_units_data buffer space used to hold the values from * * the call to convert_to_units for each * * data level requested (used so only 1 call * * is needed per data value) * * * * INTERNAL VARIABLES * * struct experiment_info *ex a pointer to the structure that holds * * specific experiment information * * struct fill_mode *fptr pointer to the fill_mode structure being * * processed * * struct fill_sensor *sptr pointer to the fill_sensor structure being * * processed * * struct in_fill *mptr pointer to the data level combination being * * processed * * register SDDAS_FLOAT *dptr pointer to the data array * * reg SDDAS_FLOAT *tmp_buf pointer to the converted data levels * * register SDDAS_FLOAT *tfrac pointer to the normalization factors * * register SDDAS_SHORT i looping varible * * reg SDDAS_CHAR *bin_stat pointer to the bin status array * * SDDAS_FLOAT set_frac the fraction of the data value to be added * * to or included in the buffer * * SDDAS_FLOAT *base_data pointer to BUFFER 0 for this mode * * SDDAS_FLOAT *base_frac pointer to BUFFER 0 normalization factors * * for this mode * * SDDAS_LONG offset offset value to get to the data of interest * * SDDAS_LONG start_pix starting pixel location for this buffer * * SDDAS_LONG stop_pix ending pixel location for this buffer * * SDDAS_LONG num_pix number of pixels covered by this buffer * * SDDAS_LONG end_sec, end time, in terms of the base time and * * end_nsec resolution, for the buffer's start pixel * * SDDAS_SHORT new_buffer next free buffer to be used * * SDDAS_SHORT yr, day temporary year and dayofyear values * * SDDAS_CHAR *base_bin pointer to BUFFER 0 bin status array for * * this mode * * * * SUBSYSTEM * * Display Level * * * ******************************************************************************/ SDDAS_SHORT ir_full_mode_pixels (SDDAS_LONG pix_start, SDDAS_LONG pix_end, SDDAS_CHAR buf_num, SDDAS_SHORT index, SDDAS_CHAR chk_buffers, SDDAS_SHORT *pix_yr, SDDAS_SHORT *pix_day, SDDAS_LONG *pix_sec, SDDAS_LONG *pix_nsec, void *idf_data_ptr) { extern struct general_info ginfo; extern SDDAS_FLOAT *ir_units_data; struct experiment_info *ex; struct fill_mode *fptr; struct fill_sensor *sptr; struct in_fill *mptr; register SDDAS_FLOAT *dptr, *tmp_buf, *tfrac; register SDDAS_SHORT i; register SDDAS_CHAR *bin_stat; SDDAS_FLOAT set_frac, *base_data, *base_frac; SDDAS_LONG offset, start_pix, stop_pix, num_pix, end_sec, end_nsec; SDDAS_SHORT new_buffer, yr, day; SDDAS_CHAR *base_bin; /*******************************************************************/ /* The pixels in between the start and end pixel utilize 100% of */ /* the data value. The buffer is terminated and is ready to be */ /* plotted. No need for += since not associated with working pix.*/ /* Time variables are cumulative from the base reference time; */ /* nanosecond component already adjusted to stay within range. */ /*******************************************************************/ ex = ginfo.expt; fptr = ex->mode_arrays; ir_next_pixel_time ((SDDAS_LONG) 1, pix_sec, pix_nsec, 1); start_pix = pix_start + 1; stop_pix = pix_end - 1; num_pix = (stop_pix - start_pix) + 1; set_frac = 1.00000; end_sec = *pix_sec; yr = *pix_yr; day = *pix_day; adjust_time (&yr, &day, &end_sec, 1); *(fptr->bpix + buf_num) = start_pix; *(fptr->epix + buf_num) = stop_pix; *(fptr->btime_sec + buf_num) = end_sec; *(fptr->btime_nsec + buf_num) = *pix_nsec; *(fptr->btime_day + buf_num) = day; *(fptr->btime_yr + buf_num) = yr; /*****************************************************************/ /* Since buffers are time contiguous, the stop of one is the */ /* start of the next. */ /*****************************************************************/ end_sec = *pix_sec; end_nsec = *pix_nsec; ir_next_pixel_time (num_pix, &end_sec, &end_nsec, 1); yr = *pix_yr; day = *pix_day; adjust_time (&yr, &day, &end_sec, 1); *(fptr->etime_sec + buf_num) = end_sec; *(fptr->etime_nsec + buf_num) = end_nsec; *(fptr->etime_day + buf_num) = day; *(fptr->etime_yr + buf_num) = yr; *(fptr->buf_stat + buf_num) = BUFFER_READY; /*********************************************************************/ /* Set the data pointer to the beginning of the first buffer (buf 0)*/ /* for this mode. */ /*********************************************************************/ offset = NUM_BUFFERS * *(fptr->num_units + index); base_data = fptr->data + offset; base_frac = fptr->tot_frac + offset; base_bin = fptr->bin_stat + offset; /********************************************************************/ /* Set the data pointer to the first sub-buffer associated with */ /* the data buffer (0-4) being processed. */ /********************************************************************/ sptr = ex->mode_info_ptr + *(fptr->ind_fill_mode + index); offset = buf_num * sptr->num_units; dptr = base_data + offset; tfrac = base_frac + offset; bin_stat = base_bin + offset; /***********************************************************************/ /* Transfer the converted data into the buffers for all data levels. */ /* Index into ir_units_data by one since only one mode value is */ /* returned by READ_DREC(). */ /***********************************************************************/ offset = 0; tmp_buf = ir_units_data; for (i = 0; i < sptr->num_units; ++i, offset += 1, tmp_buf +=1) { mptr = sptr->min_max_app + i; ir_mode_buffer (&mptr->sen_min, set_frac, offset, dptr, tfrac, bin_stat, tmp_buf); } ir_next_pixel_time (num_pix, pix_sec, pix_nsec, 1); /******************************************************************/ /* Get the next available free buffer. */ /******************************************************************/ new_buffer = ir_get_mode_buffer_number (buf_num, chk_buffers); return (new_buffer); }