<jupyter_start><jupyter_text>Compute the approximate CHEOPS count rate[CHEOPS red book](https://sci.esa.int/documents/34375/36249/1567259940843-CHEOPS_EST_SCI_RP_001_RedBook_i1.0.pdf)<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

import astropy.units as u
from astropy.constants import R_earth, R_sun

import tynt
from synphot.spectrum import SpectralElement, SourceSpectrum
from synphot.observation import Observation
from synphot import BlackBody1D
from synphot.models import Empirical1D<jupyter_output><empty_output><jupyter_text>Set parameters for white dwarf and CHEOPS:<jupyter_code># Parameters for WD 1134+300
distance = (63.7842 * u.mas).to(u.pc, u.parallax())
T_eff = 22000 * u.K
stellar_radius = 1 * R_earth

# CHEOPS props:
aperture_radius = 30 / 2 * u.cm  # radius of 3.5m ARC telescope at APO
gain = 1.9  # the gain of this detector in e-/ADU
band = 'GAIA/GAIA0.G' # CHEOPS bp is approx Gaia G<jupyter_output><empty_output><jupyter_text>Set source spectrum to blackbody:<jupyter_code>photlam = SourceSpectrum(BlackBody1D, temperature=T_eff)

# Scale the flux to get the value at Earth
photlam = photlam * float(stellar_radius / distance) ** 2

photlam.plot(flux_unit='Jy', left=1000, right=11000)<jupyter_output><empty_output><jupyter_text>Approximate the filter bandpass:<jupyter_code>f = tynt.FilterGenerator()

filt = f.reconstruct(band)
bp = SpectralElement(Empirical1D,
                     points=filt.wavelength,
                     lookup_table=filt.transmittance)
bp.plot()<jupyter_output><empty_output><jupyter_text>Approximate quantum efficiency of a typical CCD:<jupyter_code>quantum_efficiency = SpectralElement.from_file('../aspros/data/ccd_QE.csv', wave_unit="nm")
quantum_efficiency = quantum_efficiency / 100  # convert percentages to decimals

quantum_efficiency.plot(left=3000, right=14000)<jupyter_output><empty_output><jupyter_text>Compute the count rate:<jupyter_code>observation = Observation(photlam, bp * quantum_efficiency)
aperture_area = np.pi * aperture_radius ** 2
countrate = observation.countrate(area=aperture_area) / gain

countrate
with open('../aspros/data/count_rate.txt', 'w') as w: 
    w.write(str(countrate.to(u.ct/u.s).value))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10217681030653043, 'fraction_numerical': 0.03642825410928476, 'mean_word_length': 6.015576323987539, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '276485', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 896, 'n_tokens_neox': 785, 'n_words': 166, 'path': 'notebooks/synphot.ipynb', 'repo_name': 'bmorris3/aspros', 'size': '2251'}