#--------------------------------------------------------------------------- .help dst_open_data May92 hrs .ih NAME dst_open_data -- Open/Reopen the various data files. .endhelp #--------------------------------------------------------------------------- procedure dst_open_data (file, group, grp_image, extracted_image, special_image) char file[ARB] # I: Science data image name. int group # I: Current group member to open. pointer grp_image # IO: Image descriptor for the data. pointer extracted_image # IO: Image descriptor for the trailer data. pointer special_image # IO: Image descriptor for special diodes. # Declarations. real datamin, datamax # Data minimum, maximum (not used.) int i # Generic. pointer dir # Directory part of file. pointer ext # Extension part of file. pointer root # Root part of file. pointer sp # Stack pointer. pointer tmp_string # Generic temporary string. string extracted_ext ".x0h" string cal_data_ext "c1h" string special_ext ".c3h" # Function prototypes. int fnextn(), fnldir(), fnroot() bool streq() pointer immap() begin call smark (sp) call salloc (dir, SZ_LINE, TY_CHAR) call salloc (ext, SZ_LINE, TY_CHAR) call salloc (root, SZ_LINE, TY_CHAR) call salloc (tmp_string, SZ_LINE, TY_CHAR) # If this is the first group, actually open a new image. if (group == 1) { # Close previous images if this is the first group. if (grp_image != NULL) call imunmap (grp_image) if (extracted_image != NULL) call imunmap (extracted_image) if (special_image != NULL) call imunmap (special_image) # Open data file. If there is an error, just die. iferr (grp_image = immap (file, READ_ONLY, 0)) { call sprintf (Memc[tmp_string], SZ_LINE, "could not open file %s") call pargstr (file) call error (1, Memc[tmp_string]) } # Break file name up. i = fnldir (file, Memc[dir], SZ_LINE) i = fnroot (file, Memc[root], SZ_LINE) i = fnextn (file, Memc[ext], SZ_LINE) # Open the trailer. call strcpy (Memc[dir], Memc[tmp_string], SZ_LINE) call strcat (Memc[root], Memc[tmp_string], SZ_LINE) call strcat (extracted_ext, Memc[tmp_string], SZ_LINE) iferr (extracted_image = immap (Memc[tmp_string], READ_ONLY, 0)) { call eprintf ("Warning: Could not open trailer data file %s\n") call pargstr (Memc[tmp_string]) extracted_image = NULL } # Open the calibrated special diode file if using calibrated data. if (streq (cal_data_ext, Memc[ext])) { call strcpy (Memc[dir], Memc[tmp_string], SZ_LINE) call strcat (Memc[root], Memc[tmp_string], SZ_LINE) call strcat (special_ext, Memc[tmp_string], SZ_LINE) iferr (special_image = immap (Memc[tmp_string], READ_ONLY, 0)) { call eprintf ("Warning: Could not open special diode data file %s\n") call pargstr (Memc[tmp_string]) special_image = NULL } } else special_image = NULL } # Else, just open another group in the current images. else { # Open the next data group. iferr (call gf_opengr (grp_image, group, datamin, datamax, 0)) { call sprintf (Memc[tmp_string], SZ_LINE, "could not get group %d of file %s") call pargi (group) call pargstr (file) } # Open next trailer group. if (extracted_image != NULL) iferr (call gf_opengr (extracted_image, group, datamin, datamax, 0)) { call sprintf (Memc[tmp_string], SZ_LINE, "could not get group %d of extracted data for file %s") call pargi (group) call pargstr (file) } # Open next special diode group. if (special_image != NULL) iferr (call gf_opengr (special_image, group, datamin, datamax, 0)) { call sprintf (Memc[tmp_string], SZ_LINE, "could not get group %d of special diode for file %s") call pargi (group) call pargstr (file) } } call sfree (sp) end #--------------------------------------------------------------------------- # End of dst_open_data #---------------------------------------------------------------------------