Highlight

2024-03-18

Don't forget to check your integer type!

"""PIL/Pillow Image.fromarray() doesn't check your array value types!"""

from PIL import Image
import numpy as np


im = Image.new("RGB", (2, 1))
im.putpixel((0, 0), (255, 0, 0))
im.putpixel((1, 0), (0, 255, 0))

a = np.array(im)
print("Good shape:", a.shape, a)
print("See?")
Image.fromarray(a, "RGB").show()

a = np.array([[[255, 0, 0], [0, 255, 0]]])
print("Bad shape:", a.shape, a)
print("Where'd the green pixel go?")
Image.fromarray(a, "RGB").show()

a = np.uint8(a)
print("Fixed shape:", a.shape, a)
print("If the green pixel disappeared, you forgot to cast to uint8.")
Image.fromarray(a, "RGB").show()

Coal ash contains more energy than was gained from burning the coal.

https://www.world-nuclear.org/information-library/facts-and-figures/heat-values-of-various-fuels.aspx

Natural uranium, in FNR 28,000 GJ/kg [so 28e9 J/g]
Hard black coal (IEA definition) >23.9 MJ/kg
Hard black coal (Australia & Canada) c. 25 MJ/kg [so 25e3 J/g and 207.25 g/mol according to https://pubchem.ncbi.nlm.nih.gov/compound/1-Anthrylmethanolate]
Sub-bituminous coal (IEA definition) 17.4-23.9 MJ/kg
Sub-bituminous coal (Australia & Canada) c. 18 MJ/kg
Lignite/brown coal (IEA definition) <17.4 MJ/kg
Lignite/brown coal (Australia, electricity) c. 10 MJ/kg


mass / molar mass = moles

moles * avogardo = number of molecules


number / avogadro = moles

moles * molar mass = mass


1e6 / 6.022140857e24 * 207.25 = 3.4414672e-17 g of coal = 8.603668e-13 J (25e3 J/g * 3.4414672e-17 g)

1 / 6.022140857e24 * 238.02891 = 3.952563e-23 g of uranium = 1.1067176e-12 J (28e9 J/g * 3.952563e-23 g)

1 / 6.022140857e24 * 232.03806 = 3.8530826e-23 g of thorium = 1.0788631e-12 J (28e9 J/g * 3.8530826e-23)


https://pubs.usgs.gov/fs/1997/fs163-97/FS-163-97.html

"2,000 coal samples from the Western United States and approximately 300 coals from the Illinois Basin. In the majority of samples, concentrations of uranium fall in the range from slightly below 1 to 4 parts per million (ppm). Similar uranium concentrations are found in a variety of common rocks and soils, as indicated in figure 2. Coals with more than 20 ppm uranium are rare in the United States. Thorium concentrations in coal fall within a similar 1–4 ppm range"


So at 1 ppm uranium and 1 ppm thorium, a coal power plant releases only (8.603668e-13 / (1.1067176e-12 + 1.0788631e-12)) = 0.3936559286 = 39% of the available energy in coal.