The grism flat calibration consists of two parts. The first part is an overall grism flat adjustment. This is generated by comparing the total flux in the primary orders (1st for NUV and 2nd for FUV) for a given star at various positions on each detector (see 'N/FUV_grism_flat-00.fits'). The second part are the wavelength dependent flats which are divided into a few to several sections in each primary band and are 'relative' to the '*grism_flat-00.fits' files (see 'N/FUV_relative_grism_flat-##.fits').
I used a program 'gsrot.c' (in /users/tab/c/aux/), to generate a table (e.g. '/home/runes3/tab/redux/calib/lds/data/fuv.tbl') using 'do.g' script. This also generated f/nuv.tbl.#.txt files for the *-00.fits file and the relative *-##.fits files.
Then I used an IDL procedure created by Patrick to create smoothed 'flat' images (see /home/runes3/tab/redux/calib/lds/data/m.pro). This creates N/FUV_delta.#.fits images. These images are then normalized by the script 'do.normal'. Each image is divided by a mean in the image to create 'N/FUV_normal.#.fits'. Each of the files N/FUV_normal.(1...).fits are then divided by N/FUV_normal.0.fits to create the N/FUV_relative_grism_flat-##.fits files.
Normalization is justified here since any final scaling (possibly wavelength dependent) will be taken care of by generating a new overall high resolution effective area curve after applying these new grism flats.
We want to apply the 'N/FUV_grism_flat-00.fits' images to background of the grism data. In the program 'galexspac', I multiply this data into the direct image flat (response) image (see '-rrhr.fits').
Let's define 'Fxi' as the background substracted flux of an object at image prosition 'i' and wavelength position 'x'. 'Bi' is the background flux at 'i'. 'DRi' is the direct response image (*-rrhr.fits) at 'i'. 'BGFi' is the background grism flat at 'i' (see 'N/FUV_grism_flat-00.fits'). 'RGFxj' is the relative grism flat at 'x'. Here 'j' is the image position of the middle of the primary order.
We can get 'Fxi' by dividing everything by 'DRi' times 'BGFi' and subtracting off the background. The raw photon counts and this product of 'DRi' and 'BGFi' appears in the image strip files (-pri.fits) which are generated by the 'galexspac' program. The last row of the response image strip contains smoothed values of 'RGFxj' at each wavelength point (column). The division and background correction are done in the 'galexspex' program.
To adjust for the wavelength dependent flat we divide 'Fxi' by 'RGFxj' at each wavelength point in the program 'galexspex', where 'RGFxj' is taken from the last row in the response image strip (in -pri.fits).
Note that the relative grism flat values 'RGFj' are taken at the middle of the primary order, not the precise image position at each wavelength. Since the grism flat does not have high spatial precision this is probably OK for now.