quasarnp.utils

A module containing facilities for rebinning data and processing QuasarNP output.

There are three methods in this module, one that will process the output of QuasarNP into a human parsable form, and two that are used to rebin the DESI wavelength grid into the QuasarNet wavelength grid. In addition, there is a global dictionary that maps emission line names to their rest wavelength.

quasarnp.utils.process_preds(preds, lines, lines_bal, verbose=True, wave=array([3600., 3608.29885708, 3616.616845, 3624.95400787, 3633.31038988, 3641.68603534, 3650.08098865, 3658.49529433, 3666.92899699, 3675.38214135, 3683.85477221, 3692.34693451, 3700.85867326, 3709.39003359, 3717.94106074, 3726.51180005, 3735.10229694, 3743.71259698, 3752.34274582, 3760.99278919, 3769.66277298, 3778.35274315, 3787.06274576, 3795.79282701, 3804.54303317, 3813.31341064, 3822.10400592, 3830.91486561, 3839.74603643, 3848.5975652, 3857.46949886, 3866.36188443, 3875.27476907, 3884.20820003, 3893.16222467, 3902.13689048, 3911.13224502, 3920.148336, 3929.18521122, 3938.24291858, 3947.32150612, 3956.42102196, 3965.54151435, 3974.68303165, 3983.84562232, 3993.02933494, 4002.23421821, 4011.46032093, 4020.70769201, 4029.97638048, 4039.26643549, 4048.57790628, 4057.91084223, 4067.26529282, 4076.64130765, 4086.03893642, 4095.45822896, 4104.89923522, 4114.36200524, 4123.8465892, 4133.35303739, 4142.8814002, 4152.43172816, 4162.00407189, 4171.59848216, 4181.21500983, 4190.85370588, 4200.51462142, 4210.19780767, 4219.90331597, 4229.63119778, 4239.38150467, 4249.15428835, 4258.94960061, 4268.7674934, 4278.60801877, 4288.4712289, 4298.35717607, 4308.26591271, 4318.19749134, 4328.15196462, 4338.12938534, 4348.12980638, 4358.15328078, 4368.19986167, 4378.26960233, 4388.36255613, 4398.47877659, 4408.61831735, 4418.78123217, 4428.96757492, 4439.17739962, 4449.4107604, 4459.66771151, 4469.94830733, 4480.25260238, 4490.58065127, 4500.93250878, 4511.30822979, 4521.7078693, 4532.13148246, 4542.57912453, 4553.0508509, 4563.54671709, 4574.06677875, 4584.61109166, 4595.17971172, 4605.77269497, 4616.39009756, 4627.0319758, 4637.6983861, 4648.38938501, 4659.10502922, 4669.84537554, 4680.61048092, 4691.40040243, 4702.21519727, 4713.0549228, 4723.91963647, 4734.80939589, 4745.7242588, 4756.66428307, 4767.6295267, 4778.62004783, 4789.63590472, 4800.67715579, 4811.74385957, 4822.83607473, 4833.9538601, 4845.0972746, 4856.26637733, 4867.4612275, 4878.68188446, 4889.92840771, 4901.20085688, 4912.49929172, 4923.82377215, 4935.17435819, 4946.55111005, 4957.95408802, 4969.38335257, 4980.8389643, 4992.32098394, 5003.82947237, 5015.3644906, 5026.9260998, 5038.51436126, 5050.12933642, 5061.77108687, 5073.43967432, 5085.13516064, 5096.85760785, 5108.60707808, 5120.38363364, 5132.18733697, 5144.01825064, 5155.87643738, 5167.76196007, 5179.67488172, 5191.61526549, 5203.58317469, 5215.57867276, 5227.60182332, 5239.6526901, 5251.73133699, 5263.83782804, 5275.97222744, 5288.13459952, 5300.32500876, 5312.54351979, 5324.79019741, 5337.06510653, 5349.36831223, 5361.69987976, 5374.05987448, 5386.44836194, 5398.86540781, 5411.31107792, 5423.78543827, 5436.28855499, 5448.82049437, 5461.38132285, 5473.97110704, 5486.58991367, 5499.23780966, 5511.91486206, 5524.62113808, 5537.35670509, 5550.12163062, 5562.91598234, 5575.73982808, 5588.59323585, 5601.47627378, 5614.38901018, 5627.33151351, 5640.30385239, 5653.3060956, 5666.33831208, 5679.40057092, 5692.49294137, 5705.61549286, 5718.76829495, 5731.95141738, 5745.16493005, 5758.40890301, 5771.68340648, 5784.98851085, 5798.32428664, 5811.69080458, 5825.08813552, 5838.51635049, 5851.9755207, 5865.4657175, 5878.98701242, 5892.53947714, 5906.12318352, 5919.73820357, 5933.38460949, 5947.06247362, 5960.77186849, 5974.51286678, 5988.28554133, 6002.08996518, 6015.92621152, 6029.7943537, 6043.69446524, 6057.62661985, 6071.5908914, 6085.58735392, 6099.61608161, 6113.67714886, 6127.77063022, 6141.89660041, 6156.05513433, 6170.24630703, 6184.47019377, 6198.72686995, 6213.01641116, 6227.33889317, 6241.69439191, 6256.0829835, 6270.50474421, 6284.95975051, 6299.44807905, 6313.96980663, 6328.52501025, 6343.11376708, 6357.73615447, 6372.39224994, 6387.0821312, 6401.80587614, 6416.56356281, 6431.35526947, 6446.18107453, 6461.0410566, 6475.93529446, 6490.86386709, 6505.82685364, 6520.82433343, 6535.85638598, 6550.923091, 6566.02452835, 6581.16077811, 6596.33192054, 6611.53803605, 6626.77920529, 6642.05550905, 6657.36702832, 6672.71384429, 6688.09603833, 6703.51369199, 6718.966887, 6734.45570532, 6749.98022904, 6765.54054049, 6781.13672216, 6796.76885675, 6812.43702712, 6828.14131636, 6843.88180772, 6859.65858467, 6875.47173084, 6891.32133008, 6907.20746641, 6923.13022408, 6939.08968749, 6955.08594126, 6971.11907021, 6987.18915933, 7003.29629384, 7019.44055913, 7035.62204079, 7051.84082462, 7068.09699661, 7084.39064294, 7100.72185001, 7117.0907044, 7133.4972929, 7149.94170249, 7166.42402035, 7182.94433389, 7199.50273068, 7216.09929851, 7232.73412539, 7249.4072995, 7266.11890925, 7282.86904324, 7299.65779028, 7316.48523937, 7333.35147974, 7350.25660081, 7367.20069221, 7384.18384377, 7401.20614554, 7418.26768777, 7435.36856092, 7452.50885565, 7469.68866284, 7486.90807357, 7504.16717915, 7521.46607107, 7538.80484106, 7556.18358104, 7573.60238316, 7591.06133976, 7608.56054341, 7626.10008689, 7643.6800632, 7661.30056554, 7678.96168733, 7696.66352221, 7714.40616403, 7732.18970687, 7750.01424501, 7767.87987295, 7785.78668542, 7803.73477735, 7821.72424391, 7839.75518047, 7857.82768263, 7875.94184622, 7894.09776726, 7912.29554203, 7930.53526699, 7948.81703887, 7967.14095458, 7985.50711128, 8003.91560635, 8022.36653737, 8040.86000219, 8059.39609885, 8077.97492562, 8096.59658101, 8115.26116375, 8133.9687728, 8152.71950734, 8171.51346678, 8190.35075078, 8209.2314592, 8228.15569215, 8247.12354996, 8266.1351332, 8285.19054267, 8304.28987939, 8323.43324463, 8342.62073989, 8361.85246689, 8381.12852759, 8400.44902421, 8419.81405917, 8439.22373515, 8458.67815505, 8478.17742203, 8497.72163945, 8517.31091095, 8536.94534038, 8556.62503185, 8576.35008969, 8596.12061849, 8615.93672306, 8635.79850847, 8655.70608002, 8675.65954327, 8695.659004, 8715.70456825, 8735.7963423, 8755.93443267, 8776.11894613, 8796.3499897, 8816.62767064, 8836.95209647, 8857.32337493, 8877.74161404, 8898.20692206, 8918.71940748, 8939.27917906, 8959.88634582, 8980.54101699, 9001.24330211, 9021.99331092, 9042.79115343, 9063.63693993, 9084.53078093, 9105.47278721, 9126.46306979, 9147.50173998, 9168.58890931, 9189.72468958, 9210.90919286, 9232.14253146, 9253.42481797, 9274.75616521, 9296.13668628, 9317.56649455, 9339.04570363, 9360.57442739, 9382.15278, 9403.78087584, 9425.45882959, 9447.18675618, 9468.96477082, 9490.79298897, 9512.67152636, 9534.60049898, 9556.58002311, 9578.61021528, 9600.69119228, 9622.82307119, 9645.00596935, 9667.24000437, 9689.52529414, 9711.8619568, 9734.25011079, 9756.68987481, 9779.18136782, 9801.72470908, 9824.32001811, 9846.9674147, 9869.66701894, 9892.41895117, 9915.22333202, 9938.08028239, 9960.98992348]))[source]

Convert network output to line confidence and redshift predictions.

Parameters:
  • preds (numpy.ndarray) – Model prediction, output of model.predict.

  • lines (list of str) – List of line names.

  • lines_bal (list of str) – List of BAL line names.

  • verbose (bool, optional) – Whether or not to print verbose debug output. Defaults to True.

Returns:

  • c_line (numpy.ndarray) – Confidence that each line appears in the given spectra, with shape (nlines, nspec).

  • z_line (numpy.ndarray) – Estimated redshift of the spectra derived from each line, with shape (nlines, nspec).

  • zbest (numpy.ndarray) – Redshift of the most confident line for each spectra with length nspec.

  • c_line_bal (numpy.ndarray) – Confidence that each BAL line appears in the given spectra, with shape (nlines_bal, nspec).

  • z_line_bal (numpy.ndarray) – Estimated redshift of the spectra derived from each BAL line, with shape (nlines_bal, nspec).

Notes

This method determines the number of trained lines and BAL lines by setting nlines = len(lines) and nlines_bal = len(lines_bal).

quasarnp.utils.rebin(flux, ivar, w_grid, out_grid=array([3600., 3608.29885708, 3616.616845, 3624.95400787, 3633.31038988, 3641.68603534, 3650.08098865, 3658.49529433, 3666.92899699, 3675.38214135, 3683.85477221, 3692.34693451, 3700.85867326, 3709.39003359, 3717.94106074, 3726.51180005, 3735.10229694, 3743.71259698, 3752.34274582, 3760.99278919, 3769.66277298, 3778.35274315, 3787.06274576, 3795.79282701, 3804.54303317, 3813.31341064, 3822.10400592, 3830.91486561, 3839.74603643, 3848.5975652, 3857.46949886, 3866.36188443, 3875.27476907, 3884.20820003, 3893.16222467, 3902.13689048, 3911.13224502, 3920.148336, 3929.18521122, 3938.24291858, 3947.32150612, 3956.42102196, 3965.54151435, 3974.68303165, 3983.84562232, 3993.02933494, 4002.23421821, 4011.46032093, 4020.70769201, 4029.97638048, 4039.26643549, 4048.57790628, 4057.91084223, 4067.26529282, 4076.64130765, 4086.03893642, 4095.45822896, 4104.89923522, 4114.36200524, 4123.8465892, 4133.35303739, 4142.8814002, 4152.43172816, 4162.00407189, 4171.59848216, 4181.21500983, 4190.85370588, 4200.51462142, 4210.19780767, 4219.90331597, 4229.63119778, 4239.38150467, 4249.15428835, 4258.94960061, 4268.7674934, 4278.60801877, 4288.4712289, 4298.35717607, 4308.26591271, 4318.19749134, 4328.15196462, 4338.12938534, 4348.12980638, 4358.15328078, 4368.19986167, 4378.26960233, 4388.36255613, 4398.47877659, 4408.61831735, 4418.78123217, 4428.96757492, 4439.17739962, 4449.4107604, 4459.66771151, 4469.94830733, 4480.25260238, 4490.58065127, 4500.93250878, 4511.30822979, 4521.7078693, 4532.13148246, 4542.57912453, 4553.0508509, 4563.54671709, 4574.06677875, 4584.61109166, 4595.17971172, 4605.77269497, 4616.39009756, 4627.0319758, 4637.6983861, 4648.38938501, 4659.10502922, 4669.84537554, 4680.61048092, 4691.40040243, 4702.21519727, 4713.0549228, 4723.91963647, 4734.80939589, 4745.7242588, 4756.66428307, 4767.6295267, 4778.62004783, 4789.63590472, 4800.67715579, 4811.74385957, 4822.83607473, 4833.9538601, 4845.0972746, 4856.26637733, 4867.4612275, 4878.68188446, 4889.92840771, 4901.20085688, 4912.49929172, 4923.82377215, 4935.17435819, 4946.55111005, 4957.95408802, 4969.38335257, 4980.8389643, 4992.32098394, 5003.82947237, 5015.3644906, 5026.9260998, 5038.51436126, 5050.12933642, 5061.77108687, 5073.43967432, 5085.13516064, 5096.85760785, 5108.60707808, 5120.38363364, 5132.18733697, 5144.01825064, 5155.87643738, 5167.76196007, 5179.67488172, 5191.61526549, 5203.58317469, 5215.57867276, 5227.60182332, 5239.6526901, 5251.73133699, 5263.83782804, 5275.97222744, 5288.13459952, 5300.32500876, 5312.54351979, 5324.79019741, 5337.06510653, 5349.36831223, 5361.69987976, 5374.05987448, 5386.44836194, 5398.86540781, 5411.31107792, 5423.78543827, 5436.28855499, 5448.82049437, 5461.38132285, 5473.97110704, 5486.58991367, 5499.23780966, 5511.91486206, 5524.62113808, 5537.35670509, 5550.12163062, 5562.91598234, 5575.73982808, 5588.59323585, 5601.47627378, 5614.38901018, 5627.33151351, 5640.30385239, 5653.3060956, 5666.33831208, 5679.40057092, 5692.49294137, 5705.61549286, 5718.76829495, 5731.95141738, 5745.16493005, 5758.40890301, 5771.68340648, 5784.98851085, 5798.32428664, 5811.69080458, 5825.08813552, 5838.51635049, 5851.9755207, 5865.4657175, 5878.98701242, 5892.53947714, 5906.12318352, 5919.73820357, 5933.38460949, 5947.06247362, 5960.77186849, 5974.51286678, 5988.28554133, 6002.08996518, 6015.92621152, 6029.7943537, 6043.69446524, 6057.62661985, 6071.5908914, 6085.58735392, 6099.61608161, 6113.67714886, 6127.77063022, 6141.89660041, 6156.05513433, 6170.24630703, 6184.47019377, 6198.72686995, 6213.01641116, 6227.33889317, 6241.69439191, 6256.0829835, 6270.50474421, 6284.95975051, 6299.44807905, 6313.96980663, 6328.52501025, 6343.11376708, 6357.73615447, 6372.39224994, 6387.0821312, 6401.80587614, 6416.56356281, 6431.35526947, 6446.18107453, 6461.0410566, 6475.93529446, 6490.86386709, 6505.82685364, 6520.82433343, 6535.85638598, 6550.923091, 6566.02452835, 6581.16077811, 6596.33192054, 6611.53803605, 6626.77920529, 6642.05550905, 6657.36702832, 6672.71384429, 6688.09603833, 6703.51369199, 6718.966887, 6734.45570532, 6749.98022904, 6765.54054049, 6781.13672216, 6796.76885675, 6812.43702712, 6828.14131636, 6843.88180772, 6859.65858467, 6875.47173084, 6891.32133008, 6907.20746641, 6923.13022408, 6939.08968749, 6955.08594126, 6971.11907021, 6987.18915933, 7003.29629384, 7019.44055913, 7035.62204079, 7051.84082462, 7068.09699661, 7084.39064294, 7100.72185001, 7117.0907044, 7133.4972929, 7149.94170249, 7166.42402035, 7182.94433389, 7199.50273068, 7216.09929851, 7232.73412539, 7249.4072995, 7266.11890925, 7282.86904324, 7299.65779028, 7316.48523937, 7333.35147974, 7350.25660081, 7367.20069221, 7384.18384377, 7401.20614554, 7418.26768777, 7435.36856092, 7452.50885565, 7469.68866284, 7486.90807357, 7504.16717915, 7521.46607107, 7538.80484106, 7556.18358104, 7573.60238316, 7591.06133976, 7608.56054341, 7626.10008689, 7643.6800632, 7661.30056554, 7678.96168733, 7696.66352221, 7714.40616403, 7732.18970687, 7750.01424501, 7767.87987295, 7785.78668542, 7803.73477735, 7821.72424391, 7839.75518047, 7857.82768263, 7875.94184622, 7894.09776726, 7912.29554203, 7930.53526699, 7948.81703887, 7967.14095458, 7985.50711128, 8003.91560635, 8022.36653737, 8040.86000219, 8059.39609885, 8077.97492562, 8096.59658101, 8115.26116375, 8133.9687728, 8152.71950734, 8171.51346678, 8190.35075078, 8209.2314592, 8228.15569215, 8247.12354996, 8266.1351332, 8285.19054267, 8304.28987939, 8323.43324463, 8342.62073989, 8361.85246689, 8381.12852759, 8400.44902421, 8419.81405917, 8439.22373515, 8458.67815505, 8478.17742203, 8497.72163945, 8517.31091095, 8536.94534038, 8556.62503185, 8576.35008969, 8596.12061849, 8615.93672306, 8635.79850847, 8655.70608002, 8675.65954327, 8695.659004, 8715.70456825, 8735.7963423, 8755.93443267, 8776.11894613, 8796.3499897, 8816.62767064, 8836.95209647, 8857.32337493, 8877.74161404, 8898.20692206, 8918.71940748, 8939.27917906, 8959.88634582, 8980.54101699, 9001.24330211, 9021.99331092, 9042.79115343, 9063.63693993, 9084.53078093, 9105.47278721, 9126.46306979, 9147.50173998, 9168.58890931, 9189.72468958, 9210.90919286, 9232.14253146, 9253.42481797, 9274.75616521, 9296.13668628, 9317.56649455, 9339.04570363, 9360.57442739, 9382.15278, 9403.78087584, 9425.45882959, 9447.18675618, 9468.96477082, 9490.79298897, 9512.67152636, 9534.60049898, 9556.58002311, 9578.61021528, 9600.69119228, 9622.82307119, 9645.00596935, 9667.24000437, 9689.52529414, 9711.8619568, 9734.25011079, 9756.68987481, 9779.18136782, 9801.72470908, 9824.32001811, 9846.9674147, 9869.66701894, 9892.41895117, 9915.22333202, 9938.08028239, 9960.98992348]))[source]

Rebin flux to the QuasarNet wavelength grid.

The process for rebinning flux is as follows. First, the flux is multiplied by the ivar. Then, each bin from the old wavelength grid is assigned to a new bin on the new grid. The flux*ivar assigned to each new bin is summed and stored. The ivar assigned to each bin is also summed and stored. These rebinned values are then returned.

Parameters:
  • flux (numpy.ndarray) – Input flux array of shape (nspec, len(w_grid)).

  • ivar (numpy.ndarray) – Input ivar array of shape (nspec, len(w_grid)).

  • w_grid (numpy.ndarray) – Input wavelength grid.

  • out_grid (numpy.ndarray, optional) – The wavelength grid to rebin the loaded exposure to. Defaults to the logarithmic QuasarNET grid.

Returns:

  • flux_out (numpy.ndarray) – Input flux rebinned onto the QuasarNet wavelength grid.

  • ivar_out (numpy.ndarray) – Input ivar rebinned onto the QuasarNet wavelength grid.

See also

regrid

Function that converts the old wavelength grid to the new grid.

quasarnp.utils.regrid(old_grid, new_grid=array([3600., 3608.29885708, 3616.616845, 3624.95400787, 3633.31038988, 3641.68603534, 3650.08098865, 3658.49529433, 3666.92899699, 3675.38214135, 3683.85477221, 3692.34693451, 3700.85867326, 3709.39003359, 3717.94106074, 3726.51180005, 3735.10229694, 3743.71259698, 3752.34274582, 3760.99278919, 3769.66277298, 3778.35274315, 3787.06274576, 3795.79282701, 3804.54303317, 3813.31341064, 3822.10400592, 3830.91486561, 3839.74603643, 3848.5975652, 3857.46949886, 3866.36188443, 3875.27476907, 3884.20820003, 3893.16222467, 3902.13689048, 3911.13224502, 3920.148336, 3929.18521122, 3938.24291858, 3947.32150612, 3956.42102196, 3965.54151435, 3974.68303165, 3983.84562232, 3993.02933494, 4002.23421821, 4011.46032093, 4020.70769201, 4029.97638048, 4039.26643549, 4048.57790628, 4057.91084223, 4067.26529282, 4076.64130765, 4086.03893642, 4095.45822896, 4104.89923522, 4114.36200524, 4123.8465892, 4133.35303739, 4142.8814002, 4152.43172816, 4162.00407189, 4171.59848216, 4181.21500983, 4190.85370588, 4200.51462142, 4210.19780767, 4219.90331597, 4229.63119778, 4239.38150467, 4249.15428835, 4258.94960061, 4268.7674934, 4278.60801877, 4288.4712289, 4298.35717607, 4308.26591271, 4318.19749134, 4328.15196462, 4338.12938534, 4348.12980638, 4358.15328078, 4368.19986167, 4378.26960233, 4388.36255613, 4398.47877659, 4408.61831735, 4418.78123217, 4428.96757492, 4439.17739962, 4449.4107604, 4459.66771151, 4469.94830733, 4480.25260238, 4490.58065127, 4500.93250878, 4511.30822979, 4521.7078693, 4532.13148246, 4542.57912453, 4553.0508509, 4563.54671709, 4574.06677875, 4584.61109166, 4595.17971172, 4605.77269497, 4616.39009756, 4627.0319758, 4637.6983861, 4648.38938501, 4659.10502922, 4669.84537554, 4680.61048092, 4691.40040243, 4702.21519727, 4713.0549228, 4723.91963647, 4734.80939589, 4745.7242588, 4756.66428307, 4767.6295267, 4778.62004783, 4789.63590472, 4800.67715579, 4811.74385957, 4822.83607473, 4833.9538601, 4845.0972746, 4856.26637733, 4867.4612275, 4878.68188446, 4889.92840771, 4901.20085688, 4912.49929172, 4923.82377215, 4935.17435819, 4946.55111005, 4957.95408802, 4969.38335257, 4980.8389643, 4992.32098394, 5003.82947237, 5015.3644906, 5026.9260998, 5038.51436126, 5050.12933642, 5061.77108687, 5073.43967432, 5085.13516064, 5096.85760785, 5108.60707808, 5120.38363364, 5132.18733697, 5144.01825064, 5155.87643738, 5167.76196007, 5179.67488172, 5191.61526549, 5203.58317469, 5215.57867276, 5227.60182332, 5239.6526901, 5251.73133699, 5263.83782804, 5275.97222744, 5288.13459952, 5300.32500876, 5312.54351979, 5324.79019741, 5337.06510653, 5349.36831223, 5361.69987976, 5374.05987448, 5386.44836194, 5398.86540781, 5411.31107792, 5423.78543827, 5436.28855499, 5448.82049437, 5461.38132285, 5473.97110704, 5486.58991367, 5499.23780966, 5511.91486206, 5524.62113808, 5537.35670509, 5550.12163062, 5562.91598234, 5575.73982808, 5588.59323585, 5601.47627378, 5614.38901018, 5627.33151351, 5640.30385239, 5653.3060956, 5666.33831208, 5679.40057092, 5692.49294137, 5705.61549286, 5718.76829495, 5731.95141738, 5745.16493005, 5758.40890301, 5771.68340648, 5784.98851085, 5798.32428664, 5811.69080458, 5825.08813552, 5838.51635049, 5851.9755207, 5865.4657175, 5878.98701242, 5892.53947714, 5906.12318352, 5919.73820357, 5933.38460949, 5947.06247362, 5960.77186849, 5974.51286678, 5988.28554133, 6002.08996518, 6015.92621152, 6029.7943537, 6043.69446524, 6057.62661985, 6071.5908914, 6085.58735392, 6099.61608161, 6113.67714886, 6127.77063022, 6141.89660041, 6156.05513433, 6170.24630703, 6184.47019377, 6198.72686995, 6213.01641116, 6227.33889317, 6241.69439191, 6256.0829835, 6270.50474421, 6284.95975051, 6299.44807905, 6313.96980663, 6328.52501025, 6343.11376708, 6357.73615447, 6372.39224994, 6387.0821312, 6401.80587614, 6416.56356281, 6431.35526947, 6446.18107453, 6461.0410566, 6475.93529446, 6490.86386709, 6505.82685364, 6520.82433343, 6535.85638598, 6550.923091, 6566.02452835, 6581.16077811, 6596.33192054, 6611.53803605, 6626.77920529, 6642.05550905, 6657.36702832, 6672.71384429, 6688.09603833, 6703.51369199, 6718.966887, 6734.45570532, 6749.98022904, 6765.54054049, 6781.13672216, 6796.76885675, 6812.43702712, 6828.14131636, 6843.88180772, 6859.65858467, 6875.47173084, 6891.32133008, 6907.20746641, 6923.13022408, 6939.08968749, 6955.08594126, 6971.11907021, 6987.18915933, 7003.29629384, 7019.44055913, 7035.62204079, 7051.84082462, 7068.09699661, 7084.39064294, 7100.72185001, 7117.0907044, 7133.4972929, 7149.94170249, 7166.42402035, 7182.94433389, 7199.50273068, 7216.09929851, 7232.73412539, 7249.4072995, 7266.11890925, 7282.86904324, 7299.65779028, 7316.48523937, 7333.35147974, 7350.25660081, 7367.20069221, 7384.18384377, 7401.20614554, 7418.26768777, 7435.36856092, 7452.50885565, 7469.68866284, 7486.90807357, 7504.16717915, 7521.46607107, 7538.80484106, 7556.18358104, 7573.60238316, 7591.06133976, 7608.56054341, 7626.10008689, 7643.6800632, 7661.30056554, 7678.96168733, 7696.66352221, 7714.40616403, 7732.18970687, 7750.01424501, 7767.87987295, 7785.78668542, 7803.73477735, 7821.72424391, 7839.75518047, 7857.82768263, 7875.94184622, 7894.09776726, 7912.29554203, 7930.53526699, 7948.81703887, 7967.14095458, 7985.50711128, 8003.91560635, 8022.36653737, 8040.86000219, 8059.39609885, 8077.97492562, 8096.59658101, 8115.26116375, 8133.9687728, 8152.71950734, 8171.51346678, 8190.35075078, 8209.2314592, 8228.15569215, 8247.12354996, 8266.1351332, 8285.19054267, 8304.28987939, 8323.43324463, 8342.62073989, 8361.85246689, 8381.12852759, 8400.44902421, 8419.81405917, 8439.22373515, 8458.67815505, 8478.17742203, 8497.72163945, 8517.31091095, 8536.94534038, 8556.62503185, 8576.35008969, 8596.12061849, 8615.93672306, 8635.79850847, 8655.70608002, 8675.65954327, 8695.659004, 8715.70456825, 8735.7963423, 8755.93443267, 8776.11894613, 8796.3499897, 8816.62767064, 8836.95209647, 8857.32337493, 8877.74161404, 8898.20692206, 8918.71940748, 8939.27917906, 8959.88634582, 8980.54101699, 9001.24330211, 9021.99331092, 9042.79115343, 9063.63693993, 9084.53078093, 9105.47278721, 9126.46306979, 9147.50173998, 9168.58890931, 9189.72468958, 9210.90919286, 9232.14253146, 9253.42481797, 9274.75616521, 9296.13668628, 9317.56649455, 9339.04570363, 9360.57442739, 9382.15278, 9403.78087584, 9425.45882959, 9447.18675618, 9468.96477082, 9490.79298897, 9512.67152636, 9534.60049898, 9556.58002311, 9578.61021528, 9600.69119228, 9622.82307119, 9645.00596935, 9667.24000437, 9689.52529414, 9711.8619568, 9734.25011079, 9756.68987481, 9779.18136782, 9801.72470908, 9824.32001811, 9846.9674147, 9869.66701894, 9892.41895117, 9915.22333202, 9938.08028239, 9960.98992348]))[source]

Generate the mapping from the old wavelength grid to the QuasarNet grid.

Parameters:
  • old_grid (numpy.ndarray) – The old wavelength grid.

  • new_grid (numpy.ndarray, optional) – The wavelength grid to rebin the loaded exposure to. Defaults to the logarithmic QuasarNET grid.

Returns:

  • bins (numpy.ndarray) – Array of length len(old_grid) where each element is the bin number in the new grid that the old wavelength bin is assigned to.

  • w (numpy.ndarray) – Array of length len(old_grid) where each element is True if the old wavelength bin is contained within the new grid boundaries and False if it is not.

quasarnp.utils.renormalize(flux, ivar)[source]

Renormalize the flux for processing with QuasarNet.

The process for renormalizing flux is as follows. First, the weighted mean of the flux is calculated, with the ivar as weights. Then the weighted root mean squared value of the flux minus the mean is computed, once again using the ivar as weights. The renormalized flux is the initial flux minus the weighted mean and then divided by the rms value.

Parameters:
  • flux (numpy.ndarray) – Input flux array of shape (nspec, len(w_grid)).

  • ivar (numpy.ndarray) – Input ivar array of shape (nspec, len(w_grid)).

Returns:

flux_out – Input flux renormalized for use with QuasarNet.

Return type:

numpy.ndarray