def calc_toa_gain_offset(meta):
<EOL>sat_index = meta['<STR_LIT>'].upper() + "<STR_LIT:_>" + meta['<STR_LIT>'].upper()<EOL>acf = np.asarray(meta['<STR_LIT>'])  <EOL>ebw = np.asarray(meta['<STR_LIT>'])  <EOL>gain = np.asarray(constants.DG_ABSCAL_GAIN[sat_index])<EOL>scale = (acf / ebw) * gain<EOL>offset = np.asarray(constants.DG_ABSCAL_OFFSET[sat_index])<EOL>e_sun_index = meta['<STR_LIT>'].upper() + "<STR_LIT:_>" + meta['<STR_LIT>'].upper()<EOL>e_sun = np.asarray(constants.DG_ESUN[e_sun_index])<EOL>sun = ephem.Sun()<EOL>img_obs = ephem.Observer()<EOL>img_obs.lon = meta['<STR_LIT>'][<NUM_LIT:1>]<EOL>img_obs.lat = meta['<STR_LIT>'][<NUM_LIT:0>]<EOL>img_obs.elevation = meta['<STR_LIT>'][<NUM_LIT:2>]<EOL>img_obs.date = datetime.datetime.fromtimestamp(meta['<STR_LIT>']['<STR_LIT>'] / <NUM_LIT>).strftime(<EOL>'<STR_LIT>')<EOL>sun.compute(img_obs)<EOL>d_es = sun.earth_distance<EOL>theta_s = <NUM_LIT> - float(meta['<STR_LIT>'])<EOL>scale2 = (d_es ** <NUM_LIT:2> * np.pi) / (e_sun * np.cos(np.deg2rad(theta_s)))<EOL>return zip(scale, scale2, offset)<EOL>
Compute (gain, offset) tuples for each band of the specified image metadata