Skip to content

Commit

Permalink
One more bugfix
Browse files Browse the repository at this point in the history
- the second-click-bug now is really fixed
- "i/r" parameter was removed
- scrollable sources popup (it was too long)
- GitHub link was added to the info popup
- filters.py had been missed in ReadMe
  • Loading branch information
Askaniy committed Dec 27, 2021
1 parent de24b76 commit 1210efd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ Customizable output in RGB, Hex, image or spectra database table.
## Installation

**Basic installation way**

Tested on Windows 10/11 and Linux (openSUSE).

1. Clone the repository or download archive by the GitHub web interface (press the button `Code`, then I recommend choosing `Download ZIP`, unpack the archive after downloading);
2. Make sure you have Python 3.6 or higher (due to f-strings) and the required libraries: [NumPy](https://numpy.org/), [SciPy](https://www.scipy.org/), [Pillow](https://pillow.readthedocs.io/), [Plotly](https://plotly.com/python/) and [PySimpleGUI](https://pysimplegui.readthedocs.io/). If you use Anaconda, the first 4 libraries are already preinstalled. You can install the libraries all at once using [`requirements.txt`](requirements.txt): `python -m pip install -r requirements.txt`;
3. Run [TCT.py](Scripts/TCT.py)

**Executable file (no Python)**

Only for Windows. Please note that this installation way is [SevenSpheres](https://github.com/SevenSpheres)' initiative and the relevance of updates is not guaranteed.

1. Go to [releases of SevenSpheres' fork](https://github.com/SevenSpheres/TrueColorTools/releases);
Expand All @@ -26,20 +28,21 @@ Only for Windows. Please note that this installation way is [SevenSpheres](https

## How to use

[TCT.py](Scripts/TCT.py) includes three tabs for different purposes: *Spectra*, *Images* and *Table*. The first and last tabs are linked to the database, the *Images* tab asks for input. No internet connection is required.
[`TCT.py`](Scripts/TCT.py) includes three tabs for different purposes: *Spectra*, *Images* and *Table*. The first and last tabs are linked to the database, the *Images* tab asks for input. No internet connection is required.

Several global concepts:
- The wavelengths are always increasing. This is important for customizing the database and for numbering images.
- Database of spectra. Its format is just a dictionary in a Python file and is practically json. You can modify it with your own spectra, and, if you want, share data for TCT.
- Tag system. Each object in the database can be assigned an arbitrary set of tags. Same tags form a lists in the *Spectra* and *Table* tabs, which simplify interaction with a huge database.
- System of sources. Each object in the database can be easily linked to one or several sources by its number. You can see the list in `File``Sources`. Also, after an object's name there can be abbreviations, the decoding of which is indicated in `File``Notes`.

**Spectra tab** provides access to the built-in spectra database and allows you to calculate a color with the selected settings just by clicking on an object.
**Spectra tab** provides access to the built-in spectra database and allows to calculate a color with the selected settings just by clicking on an object.

For example, you can get colors formatted for [Celestia](https://github.com/CelestiaProject/Celestia), which uses chromaticity values from 0 to 1 for each color channel, where 1 is the value of the brightest channel. Make sure that the `chromaticity` mode is used and `Decimal places` is greater than zero (by default it is), and then set the `Color (bit) depth` parameter to zero.

**Images tab** allows you to load images, specify their wavelength and display a true color image, for each pixel of which a spectrum was built.
**Images tab** allows you to load image(s), specify wavelengths and save a processed image, for each pixel of which a spectrum was built. It takes a very long time with the current algorithm, so you can check out the preview.

**Table tab** generates a customizable table of calculated colors from the spectra database.
**Table tab** generates a customizable table of calculated colors from the spectra database. You can see examples [here](Tables/).


### Auxiliary
Expand All @@ -48,18 +51,19 @@ For example, you can get colors formatted for [Celestia](https://github.com/Cele
- [`calculations.py`](Scripts/calculations.py) is the mathematical core. It contains most of functions and some zero points of photometric systems;
- [`cmf.py`](Scripts/cmf.py) contains sensitivity of human perception and used curve of color space;
- [`database.py`](Scripts/database.py) contains spectra, color indices and their sources;
- [`filters.py`](Scripts/filters.py) is a database of spacecraft photometric systems;
- [`strings.py`](Scripts/strings.py) contains almost all used inscriptions of other scripts in supported languages.


## Database format

### Mandatory parameters
- `nm`: list of wavelengths in nm
- `nm`: list of wavelengths in nanometers
- `br`: same-size list of reflectivity
- `mag`: same-size list of magnitudes
- `filters`: filter system, one from convert.pyfilters
- `filters`: filter system, linked with [`filters.py`](Scripts/filters.py)
- `indices`: dictionary of color indices, use only with `filters`
- `bands`: list of filters' names, use only with `filters` and `i/f` instead of `br`
- `bands`: list of filters' names, use only with `filters`

### Optional parameters
- `albedo`: bool (`True` if reflectivity was set by albedo values) or float (in V band or on 550 nm)
Expand Down
4 changes: 2 additions & 2 deletions Scripts/TCT.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def convert_to_bytes(img):
window["T3_process"].update(tr.gui_process[lang])

elif event == tr.source[lang]:
sg.popup("\n\n".join(db.sources), title=event, line_width=120, location=(16, 25))
sg.popup_scrolled("\n\n".join(db.sources), title=event, size=(100, 20))

elif event == tr.note[lang]:
notes = []
Expand All @@ -263,7 +263,7 @@ def convert_to_bytes(img):
sg.popup("\n".join(notes), title=event)

elif event == tr.gui_info[lang]:
sg.popup(tr.auth_info[lang], title=event)
sg.popup("https://github.com/Askaniy/TrueColorTools\n"+tr.auth_info[lang], title=event)

# ------------ Events in the tab "Spectra" ------------

Expand Down
6 changes: 3 additions & 3 deletions Scripts/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ def subtract_sun(spectrum, sun):
br.append(corrected)
nm.append(sun_nm)
spectrum.update({"nm": nm, "br": br, "sun": False})
spectrum.pop("filters")

return spectrum

def transform(spectrum):
if "filters" in spectrum:
if "i/r" in spectrum:
spectrum.update({"br": spectrum["i/r"]}) # important for subtract_sun
if "bands" in spectrum:
spectrum = from_filters(spectrum) # replacement of filters for their wavelengths
elif "indices" in spectrum:
spectrum = from_indices(spectrum) # spectrum from color indices
spectrum.pop("filters")
if "mag" in spectrum:
spectrum = from_magnitudes(spectrum, database.objects["Vega|1"]) # spectrum from magnitudes
spectrum.pop("mag")
if "sun" in spectrum:
if spectrum["sun"]:
spectrum = subtract_sun(spectrum, database.objects["Sun|1"]) # subtract solar spectrum
Expand Down
12 changes: 6 additions & 6 deletions Scripts/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@
"filters": "Landolt", "indices": {"B-V": 0.67, "V-R": 0.38}, "sun": True
},
"Nereid|32": {"tags": ["featured", "solar_system", "moon", "neptunian_system", "irregular"],
"filters": "Landolt", "bands": ["U", "B", "V", "R", "I"], "i/r": [0.90, 0.93, 1, 1.13, 0.99], "albedo": 0.24 # https://arxiv.org/abs/1601.02395
"filters": "Landolt", "bands": ["U", "B", "V", "R", "I"], "br": [0.90, 0.93, 1, 1.13, 0.99], "albedo": 0.24 # https://arxiv.org/abs/1601.02395
},
"Neptunian irregulars|30": {"tags": ["featured", "solar_system", "class", "moon", "neptunian_system", "irregular"],
"filters": "Landolt", "indices": {"B-V": 0.77, "V-R": 0.50}, "sun": True
Expand Down Expand Up @@ -2224,13 +2224,13 @@
# "filters": "Hubble", "indices": {"F606W-F814W": 1.03}, "sun": True
#},
"(486958) Ultima|17": {"tags": ["featured", "solar_system", "minor_body", "tno", "classical", "classical-h"],
"filters": "New Horizons", "bands": ["blue", "red", "nir"], "i/r": [0.053, 0.079, 0.117], "sun": True, "albedo": True
"filters": "New Horizons", "bands": ["blue", "red", "nir"], "br": [0.053, 0.079, 0.117], "sun": True, "albedo": True
},
"(486958) Thule|17": {"tags": ["featured", "solar_system", "minor_body", "tno", "classical", "classical-h"],
"filters": "New Horizons", "bands": ["blue", "red", "nir"], "i/r": [0.058, 0.084, 0.122], "sun": True, "albedo": True
"filters": "New Horizons", "bands": ["blue", "red", "nir"], "br": [0.058, 0.084, 0.122], "sun": True, "albedo": True
},
'(486958) "neck"|17': {"tags": ["featured", "solar_system", "minor_body", "tno", "classical", "classical-h"],
"filters": "New Horizons", "bands": ["blue", "red", "nir"], "i/r": [0.066, 0.090, 0.125], "sun": True, "albedo": True
"filters": "New Horizons", "bands": ["blue", "red", "nir"], "br": [0.066, 0.090, 0.125], "sun": True, "albedo": True
},
"(506479) 2003 HB57|9": {"tags": ["solar_system", "minor_body", "tno", "scattered"],
"filters": "Landolt", "indices": {"B-V": 0.830, "V-R": 0.480, "R-I": 0.540}, "sun": True
Expand Down Expand Up @@ -2468,13 +2468,13 @@
"albedo": True
},
"HD 189733 b|10, 15": {"tags": ["featured", "extrasolar", "planet"],
"filters": "Landolt", "bands": ["U", "B", "V", "I"], "i/r": [0.62, 0.61, 0.28, 0], "albedo": True
"filters": "Landolt", "bands": ["U", "B", "V", "I"], "br": [0.62, 0.61, 0.28, 0], "albedo": True
},
"HD 189733 b|13, 14": {"tags": ["extrasolar", "planet"],
"nm": [290, 368, 370, 416, 459, 510, 547, 875], "br": [0.45, 0.39, 0.374, 0.32, 0.17, 0.043, 0.02, 0.025], "albedo": True
},
"Ups And b|15": {"tags": ["featured", "extrasolar", "planet"],
"filters": "Landolt", "bands": ["U", "B", "V"], "i/r": [0.53, 0.67, 0.29], "albedo": True
"filters": "Landolt", "bands": ["U", "B", "V"], "br": [0.53, 0.67, 0.29], "albedo": True
},
"WASP-18 b": {"tags": ["extrasolar", "planet"],
"nm": [440, 788, 900], "br": [0.075, 0.048, 0.05], "albedo": True
Expand Down

0 comments on commit 1210efd

Please sign in to comment.