pro write_amie, new_file, image, browse_image, new_label, line_length ;+ ;$Log: ; ; NAME: ; write_amie ; ; PURPOSE: ; Given a label, a browse image, and an image, writes a PDS compliant file ; ; CATEGORY: ; AMIE Calibration - part of 'amie_pipeline', can be used stand-alone ; ; CALLING SEQUENCE: ; write_amie, new_file, image, browse_image, new_label, line_length ; ; INPUTS: ; new_file: A string array containing the new file name ; image: The image array to be inserted in the file ; browse_image: The browse image to be inserted in the new file ; new_label: The label referent to the new file ; line_length: The length of a line in the label. By default it will be set to 80. ; ; OPTIONAL INPUT PARAMETERS: ; None. ; ; OUTPUTS: ; new AMIE PDS file ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; Hopefully none. ; ; RESTRICTIONS: ; Final output must have an atached label, a browse image and an image ; Currently only works for AMIE images, i.e. all offsets etc. are hard coded ; Image must have the bits shifted to the upper bits. ; ; MODIFICATION HISTORY: ; 2004 Feb 06, MA: First version ; 2008 Feb 14, SM: Adapting the header of the calibratied images. End-of-line marks ; correction. PDS label lines should always be terminated with ; ; (c) 2004, Miguel Almeida, ESA/RSSD ;- ;------------------------------------------------------------------------------ ;setting the line length variable in case it is not provided ;------------------------------------------------------------------------------ if keyword_set(line_length) eq 0 then begin line_length = 80 endif ;------------------------------------------------------------------------------ ;creates new file on disk ;------------------------------------------------------------------------------ openw, new_file_unit, new_file, /get_lun ;------------------------------------------------------------------------------ ;strips the carriage return and line feed, if they exist from the label lines ;------------------------------------------------------------------------------ n_lines = n_elements(new_label) for j = 0, (n_lines - 1) do begin new_label(j) = strmid(new_label(j),0,(line_length - 2)) current_length = strlen(new_label(j)) if current_length eq 0 then begin new_label(j) = ' ' endif ;; 2008-Feb-14, SM: End-of-line marks correction. PDS label lines should ;; always be terminated with ;; Old version: printf,new_file_unit, new_label(j) while (strlen(new_label[j]) lt 78) do begin new_label[j] = new_label[j] + ' ' endwhile writeu,new_file_unit,byte(new_label(j)),byte([13B,10B]) endfor ;------------------------------------------------------------------------------ ;converts the image to unsigned integer ;------------------------------------------------------------------------------ ;; 2008-Jan-13, BG: Commented this line out. The image is already ;; passed in the proper format. We want to enable writing as float. ; image = uint(image) ;------------------------------------------------------------------------------ ;writes the various parts of the image in the correct places of the file ;------------------------------------------------------------------------------ point_lun, new_file_unit, 20480 writeu, new_file_unit, browse_image point_lun, new_file_unit, 36864 writeu, new_file_unit, image close, new_file_unit free_lun, new_file_unit end