/* * 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 "@(#) work_not_inc.c 1.29 05/08/19 SwRI" #include "ret_codes.h" #include "user_defs.h" #include "gen_defs.h" #include "libtrec_idfs.h" /******************************************************************************* * * * IR_WORKING_NOT_INCLUDED SUBROUTINE * * * * DESCRIPTION * * This routine is called to process the data when the range of the start * * and end pixel locations exclude the working pixel. Time either advanced * * past the current pixel (ex. pix = 4, start = 7, stop = 8) or went back- * * wards (ex. pix = 4, start = 2, stop = 2). Since the working pixel is * * excluded, the buffer associated with the working pixel is flagged as a * * buffer that is ready to be accessed, the MORE_DATA flag is set to * * terminate processing so that the full buffers can be accessed, and the * * current working buffer number is updated. The data may cover a single * * pixel or may span many pixels. * * * * 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_LONG working_pix the current pixel location being processed * * SDDAS_LONG *pix_sec, start time, in terms of the base time and * * *pix_nsec resolution, for the buffer's start pixel * * SDDAS_SHORT *pix_yr, start time, in terms of the base time and * * *pix_day resolution, for the buffer's start pixel * * SDDAS_SHORT index indexing variable used to access the correct * * sensor variables * * SDDAS_USHORT num_sample the number of elements per data buffer * * SDDAS_SHORT sensor sensor for which data is to be retrieved * * SDDAS_FLOAT bfrac fraction of the data associated with the start* * time's pixel location (start time of the data)* * SDDAS_FLOAT efrac fraction of the data associated with the end * * time's pixel location (end time of the data) * * SDDAS_FLOAT time_frac the percentage of the time resolution covered * * by the sweep * * SDDAS_CHAR *more_data flag indicating when to terminate processing * * of data * * SDDAS_CHAR buf_num the buffer being processed (0 - 4) * * SDDAS_CHAR *last_buf the last buffer processed (0 - 4) * * SDDAS_CHAR chk_buffers flag that indicates if there is a need to * * check if all buffers have been utilized * * SDDAS_CHAR found_data flag indicating if data was returned for the * * requested sensor * * void *idf_data_ptr ptr to the memory location for the structure * * that holds returned data values (read_drec) * * SDDAS_CHAR data_envelope flag indicating if data envelope (min/max) * * or just the data sample is being processed * * * * USAGE * * x = ir_working_not_included (pix_start, pix_end, working_pix, buf_num, * * index, bfrac, efrac, &more_data, num_sample, &last_buf, chk_buffers,* * found_data, sensor, time_frac, &pix_yr, &pix_day, &pix_sec, * * &pix_nsec, idf_data_ptr, data_envelope) * * * * NECESSARY SUBPROGRAMS * * ir_transfer_to_buffer () transfers data to buffer being processed * * ir_full_pixels() processes buffers which utilize 100% of the * * data (data spans many pixels) * * ir_get_buffer_number() returns the next available buffer * * ir_next_pixel_time () determines the time of a pixel located x-many * * pixels away from the 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 concerning * * 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 fill_data *fptr pointer to the fill_data structure being * * processed * * struct fill_sensor *sptr pointer to the fill_sensor structure being * * processed * * struct bin_info *bptr a pointer to the structure that holds sweep * * binning information * * reg SDDAS_FLOAT *dptr pointer to the data array * * reg SDDAS_FLOAT *tfrac pointer to the normalization factors * * reg SDDAS_CHAR *bin_stat pointer to the bin status array * * SDDAS_FLOAT *base_data pointer to BUFFER 0 for this sensor * * SDDAS_FLOAT *base_frac pointer to BUFFER 0 normalization factors for * * this sensor * * SDDAS_FLOAT set_frac the fraction of the data value to be added * * to or included in the buffer * * SDDAS_LONG offset offset value to get to the data of interest * * 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_SHORT rval holds value returned by called module * * SDDAS_CHAR *base_bin pointer to BUFFER 0 bin status array for * * this sensor * * * * SUBSYSTEM * * Display Level * * * ******************************************************************************/ SDDAS_SHORT ir_working_not_included (SDDAS_LONG pix_start, SDDAS_LONG pix_end, SDDAS_LONG working_pix, SDDAS_CHAR buf_num, SDDAS_SHORT index, SDDAS_FLOAT bfrac, SDDAS_FLOAT efrac, SDDAS_CHAR *more_data, SDDAS_USHORT num_sample, SDDAS_CHAR *last_buf, SDDAS_CHAR chk_buffers, SDDAS_CHAR found_data, SDDAS_SHORT sensor, SDDAS_FLOAT time_frac, SDDAS_SHORT *pix_yr, SDDAS_SHORT *pix_day, SDDAS_LONG *pix_sec, SDDAS_LONG *pix_nsec, void *idf_data_ptr, SDDAS_CHAR data_envelope) { extern struct general_info ginfo; struct idf_data *EXP_DATA; struct experiment_info *ex; struct fill_data *fptr; struct fill_sensor *sptr; struct bin_info *bptr; register SDDAS_FLOAT *dptr, *tfrac; register SDDAS_CHAR *bin_stat; SDDAS_FLOAT *base_data, *base_frac, set_frac; SDDAS_LONG offset, end_sec, end_nsec; SDDAS_SHORT new_buffer, yr, day, rval; SDDAS_CHAR *base_bin; /*********************************************************************/ /* Since the time being processed excluded the working pixel, */ /* terminate the working pixel and flag it as ready to be processed.*/ /*********************************************************************/ EXP_DATA = (struct idf_data *) idf_data_ptr; ex = ginfo.expt; bptr = ex->bin_ptr; fptr = ex->fill_arrays; sptr = ex->fill_sen_ptr + *(fptr->ind_fill_sen + index); *(fptr->epix + buf_num) = working_pix; *(fptr->buf_stat + buf_num) = BUFFER_READY; /*********************************************************************/ /* Get the next available free buffer. Time variables are */ /* cumulative from the base reference time; nanosecond component */ /* already adjusted to stay within boundary range. */ /*********************************************************************/ new_buffer = ir_get_buffer_number (buf_num, chk_buffers); if (new_buffer < 0) return (new_buffer); buf_num = (SDDAS_CHAR) new_buffer; end_sec = *pix_sec; yr = *pix_yr; day = *pix_day; adjust_time (&yr, &day, &end_sec, 1); *(fptr->bpix + buf_num) = pix_start; *(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; end_sec = *pix_sec; end_nsec = *pix_nsec; ir_next_pixel_time (1, &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; /*********************************************************************/ /* Set data pointer to the beginning of the first buffer (buffer 0) */ /* for this sensor. */ /*********************************************************************/ offset = NUM_BUFFERS * *(fptr->num_units + index) * bptr->num_bins; base_data = fptr->data + offset; base_frac = fptr->tot_frac + offset; base_bin = fptr->bin_stat + offset; /*************************************************************************/ /* The start and stop time for this data value is totally associated */ /* with the same pixel (use time frac value to determine percentage of */ /* data associated with the buffer). No need for += since a new buffer */ /* is used. Flag this buffer as a working partial (not ready to be */ /* plotted). */ /*************************************************************************/ if (pix_start == pix_end) { set_frac = time_frac; *(fptr->buf_stat + buf_num) = PARTIAL_WORKING; /*****************************************************************/ /* Is this sensor to be included in the processing? */ /*****************************************************************/ if (*(ex->sensors_needed + sensor) == 1) { /********************************************************************/ /* Set the data pointer to the first sub-buffer associated with */ /* the data buffer (0-4) being processed and transfer converted */ /* data into the buffers for all data levels. */ /********************************************************************/ offset = buf_num * sptr->num_units * bptr->num_bins; dptr = base_data + offset; tfrac = base_frac + offset; bin_stat = base_bin + offset; ir_transfer_to_buffer (sptr, num_sample, found_data, sensor, set_frac, dptr, tfrac, bin_stat, idf_data_ptr, data_envelope); } /********************************************************************/ /* Process information for collapsing over multi-dimension data */ /* for data sample option, not applicable for data envelope option.*/ /********************************************************************/ if (ex->collapse_ptr != NO_MEMORY && !data_envelope) { /*****************************************************************/ /* Copy data into the phi bins if collapsing over phi dimension. */ /*****************************************************************/ if (ex->collapse_ptr->phi_bins != 1 && found_data) { rval = ir_fill_phi_bins (index, sensor, EXP_DATA->num_sample, set_frac, idf_data_ptr, buf_num); if (rval != ALL_OKAY) return (rval); } } } /*********************************************************************/ /* Set the fraction of the data that belongs to the starting pixel. */ /* No need for += since not associated with the working pixel and */ /* buffer is a terminating buffer (will be freed at next iteration).*/ /*********************************************************************/ else { set_frac = 1.0 - bfrac; *(fptr->epix + buf_num) = pix_start; *(fptr->buf_stat + buf_num) = BUFFER_READY; /*****************************************************************/ /* Is this sensor to be included in the processing? */ /*****************************************************************/ if (*(ex->sensors_needed + sensor) == 1) { /********************************************************************/ /* Set the data pointer to the first sub-buffer associated with */ /* the data buffer (0-4) being processed and transfer converted */ /* data into the buffers for all data levels. */ /********************************************************************/ offset = buf_num * sptr->num_units * bptr->num_bins; dptr = base_data + offset; tfrac = base_frac + offset; bin_stat = base_bin + offset; ir_transfer_to_buffer (sptr, num_sample, found_data, sensor, set_frac, dptr, tfrac, bin_stat, idf_data_ptr, data_envelope); } /********************************************************************/ /* Process information for collapsing over multi-dimension data */ /* for data sample option, not applicable for data envelope option.*/ /********************************************************************/ if (ex->collapse_ptr != NO_MEMORY && !data_envelope) { /*****************************************************************/ /* Copy data into the phi bins if collapsing over phi dimension. */ /*****************************************************************/ if (ex->collapse_ptr->phi_bins != 1 && found_data) { rval = ir_fill_phi_bins (index, sensor, EXP_DATA->num_sample, set_frac, idf_data_ptr, buf_num); if (rval != ALL_OKAY) return (rval); } } /*********************************************************************/ /* Get the next available free buffer. */ /*********************************************************************/ new_buffer = ir_get_buffer_number (buf_num, chk_buffers); if (new_buffer < 0) return (new_buffer); buf_num = (SDDAS_CHAR) new_buffer; /**********************************************************************/ /* The data value spans many pixels. */ /**********************************************************************/ if (pix_end - pix_start > 1) { /********************************************************************/ /* Process information for collapsing over multi-dimension data */ /* for data sample option, not applicable for data envelope option.*/ /********************************************************************/ if (ex->collapse_ptr != NO_MEMORY && !data_envelope) { /*****************************************************************/ /* Copy data into the phi bins if collapsing over phi dimension. */ /*****************************************************************/ if (ex->collapse_ptr->phi_bins != 1 && found_data) { set_frac = 1.00000; rval = ir_fill_phi_bins (index, sensor, EXP_DATA->num_sample, set_frac, idf_data_ptr, buf_num); if (rval != ALL_OKAY) return (rval); } } new_buffer = ir_full_pixels (pix_start, pix_end, buf_num, index, num_sample, chk_buffers, found_data, sensor, pix_yr, pix_day, pix_sec, pix_nsec, idf_data_ptr, data_envelope); if (new_buffer < 0) return (new_buffer); buf_num = (SDDAS_CHAR) new_buffer; } else ir_next_pixel_time ((SDDAS_LONG) 1, pix_sec, pix_nsec, 1); /*********************************************************************/ /* Set the fraction of the data that belongs to the ending pixel */ /* and set the starting pixel for the current buffer. No need for */ /* += since new buffer. Time variables are cumulative from the */ /* base reference time; nanosecond component already adjusted to */ /* stay within boundary range. */ /*********************************************************************/ set_frac = efrac; end_sec = *pix_sec; yr = *pix_yr; day = *pix_day; adjust_time (&yr, &day, &end_sec, 1); *(fptr->bpix + buf_num) = pix_end; *(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; end_sec = *pix_sec; end_nsec = *pix_nsec; ir_next_pixel_time (1, &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; /*****************************************************************/ /* Is this sensor to be included in the processing? */ /*****************************************************************/ if (*(ex->sensors_needed + sensor) == 1) { /********************************************************************/ /* Set the data pointer to the first sub-buffer associated with */ /* the data buffer (0-4) being processed and transfer converted */ /* data into the buffers for all data levels. */ /********************************************************************/ offset = buf_num * sptr->num_units * bptr->num_bins; dptr = base_data + offset; tfrac = base_frac + offset; bin_stat = base_bin + offset; ir_transfer_to_buffer (sptr, num_sample, found_data, sensor, set_frac, dptr, tfrac, bin_stat, idf_data_ptr, data_envelope); } /**********************************************************************/ /* Set the buffer status to indicate that the buffer is being worked */ /* on if the pixel is a fractional pixel. If the ending pixel is */ /* 100% covered by the data value, this buffer is also ready to be */ /* plotted (efrac will = 1.0 in this case since trailing edge). */ /**********************************************************************/ if (efrac < 1.0) *(fptr->buf_stat + buf_num) = PARTIAL_WORKING; else { *(fptr->epix + buf_num) = pix_end; *(fptr->buf_stat + buf_num) = BUFFER_READY; } /********************************************************************/ /* Process information for collapsing over multi-dimension data */ /* for data sample option, not applicable for data envelope option.*/ /********************************************************************/ if (ex->collapse_ptr != NO_MEMORY && !data_envelope) { /*****************************************************************/ /* Copy data into the phi bins if collapsing over phi dimension. */ /*****************************************************************/ if (ex->collapse_ptr->phi_bins != 1 && found_data) { rval = ir_fill_phi_bins (index, sensor, EXP_DATA->num_sample, set_frac, idf_data_ptr, buf_num); if (rval != ALL_OKAY) return (rval); } } } /*********************************************************************/ /* Set the flag to indicate that no more data needs to be */ /* accumulated in order to get a buffer that can be processed. */ /*********************************************************************/ *more_data = 0; *last_buf = buf_num; return (ALL_OKAY); }