@@ -43,8 +43,7 @@ def noise_figure_to_temp(nf_db: float, t0: float = T0) -> float:
4343 Equivalent noise temperature in Kelvin
4444
4545 Example:
46- >>> noise_figure_to_temp(3.0) # 3 dB NF
47- 288.6 # Approximately
46+ noise_figure_to_temp(3.0) # 3 dB NF -> ~288.6 K
4847 """
4948 f_linear = 10 ** (nf_db / 10 )
5049 return t0 * (f_linear - 1 )
@@ -63,8 +62,7 @@ def noise_temp_to_figure(te: float, t0: float = T0) -> float:
6362 Noise figure in dB
6463
6564 Example:
66- >>> noise_temp_to_figure(290)
67- 3.01 # Approximately
65+ noise_temp_to_figure(290) # 290 K -> ~3.01 dB
6866 """
6967 f_linear = 1 + te / t0
7068 return 10 * math .log10 (f_linear )
@@ -93,12 +91,12 @@ def friis_noise_figure(
9391 - stage_contributions_db: NF contribution from each stage
9492
9593 Example:
96- >>> # LNA (15 dB gain, 2 dB NF) -> Mixer (10 dB loss, 10 dB NF)
97- >>> result = friis_noise_figure([
98- ... (15, 2), # LNA
99- ... (-10, 10), # Mixer (loss = negative gain)
100- ... ])
101- >>> print(f"System NF: {result['total_nf_db']:.2f} dB")
94+ # LNA (15 dB gain, 2 dB NF) -> Mixer (10 dB loss, 10 dB NF)
95+ result = friis_noise_figure([
96+ (15, 2), # LNA
97+ (-10, 10), # Mixer (loss = negative gain)
98+ ])
99+ print(f"System NF: {result['total_nf_db']:.2f} dB")
102100 """
103101 if not stages :
104102 return {
@@ -166,11 +164,11 @@ def system_noise_temperature(
166164 - system_nf_db: Effective system noise figure
167165
168166 Example:
169- >>> result = system_noise_temperature(
170- ... antenna_temp_k=50, # Cold sky
171- ... receiver_nf_db=2.0,
172- ... line_loss_db=0.5
173- ... )
167+ result = system_noise_temperature(
168+ antenna_temp_k=50, # Cold sky
169+ receiver_nf_db=2.0,
170+ line_loss_db=0.5,
171+ )
174172 """
175173 # Receiver noise temperature
176174 t_rx = noise_figure_to_temp (receiver_nf_db )
@@ -210,8 +208,7 @@ def cascade_gain(gains_db: list[float]) -> float:
210208 Total gain in dB
211209
212210 Example:
213- >>> cascade_gain([20, -3, 15, -6]) # LNA, filter, amp, cable
214- 26
211+ cascade_gain([20, -3, 15, -6]) # LNA, filter, amp, cable -> 26 dB
215212 """
216213 return sum (gains_db )
217214
@@ -248,11 +245,11 @@ def cascade_iip3(
248245 - total_gain_db: Cascaded gain
249246
250247 Example:
251- >>> # LNA (15dB, +5dBm IIP3) -> Mixer (-10dB, +10dBm IIP3)
252- >>> result = cascade_iip3([
253- ... (15, 5),
254- ... (-10, 10),
255- ... ])
248+ # LNA (15dB, +5dBm IIP3) -> Mixer (-10dB, +10dBm IIP3)
249+ result = cascade_iip3([
250+ (15, 5),
251+ (-10, 10),
252+ ])
256253 """
257254 if not stages :
258255 return {"iip3_dbm" : float ('inf' ), "oip3_dbm" : float ('inf' ), "total_gain_db" : 0 }
@@ -325,11 +322,11 @@ def sfdr_from_iip3(
325322 - max_signal_dbm: Maximum signal before spurs exceed noise
326323
327324 Example:
328- >>> result = sfdr_from_iip3(
329- ... iip3_dbm=5,
330- ... noise_floor_dbm_hz=-170,
331- ... bandwidth_hz=1e6
332- ... )
325+ result = sfdr_from_iip3(
326+ iip3_dbm=5,
327+ noise_floor_dbm_hz=-170,
328+ bandwidth_hz=1e6,
329+ )
333330 """
334331 noise_floor_dbm = noise_floor_dbm_hz + 10 * math .log10 (bandwidth_hz )
335332 sfdr_db = (2 / 3 ) * (iip3_dbm - noise_floor_dbm )
@@ -387,11 +384,11 @@ def mds_from_noise_figure(
387384 - ktb_dbm: Thermal noise power
388385
389386 Example:
390- >>> result = mds_from_noise_figure(
391- ... noise_figure_db=3,
392- ... bandwidth_hz=1e6,
393- ... snr_required_db=10
394- ... )
387+ result = mds_from_noise_figure(
388+ noise_figure_db=3,
389+ bandwidth_hz=1e6,
390+ snr_required_db=10,
391+ )
395392 """
396393 # kT in dBm/Hz at T0
397394 kt_dbm_hz = 10 * math .log10 (K_B * t0 * 1000 ) # *1000 for mW
@@ -471,15 +468,15 @@ def cascade_analysis(
471468 - stage_names: Names of each stage
472469
473470 Example:
474- >>> stages = [
475- ... RFStage("LNA", gain_db=20, noise_figure_db=1.5, iip3_dbm=-5),
476- ... RFStage("Filter", gain_db=-2, noise_figure_db=2, iip3_dbm=30),
477- ... RFStage("Mixer", gain_db=-8, noise_figure_db=8, iip3_dbm=15),
478- ... RFStage("IF Amp", gain_db=30, noise_figure_db=4, iip3_dbm=10),
479- ... ]
480- >>> result = cascade_analysis(stages, bandwidth_hz=10e6)
481- >>> print(f"System NF: {result['total_nf_db']:.2f} dB")
482- >>> print(f"SFDR: {result['sfdr_db']:.1f} dB")
471+ stages = [
472+ RFStage("LNA", gain_db=20, noise_figure_db=1.5, iip3_dbm=-5),
473+ RFStage("Filter", gain_db=-2, noise_figure_db=2, iip3_dbm=30),
474+ RFStage("Mixer", gain_db=-8, noise_figure_db=8, iip3_dbm=15),
475+ RFStage("IF Amp", gain_db=30, noise_figure_db=4, iip3_dbm=10),
476+ ]
477+ result = cascade_analysis(stages, bandwidth_hz=10e6)
478+ print(f"System NF: {result['total_nf_db']:.2f} dB")
479+ print(f"SFDR: {result['sfdr_db']:.1f} dB")
483480 """
484481 if not stages :
485482 return {}
0 commit comments