Category Archives: All

All of the posts on this site.

Astropy and Astroplan

Astropy

Installation instructions: https://docs.astropy.org/en/stable/install.html

Astropy required Python packages.

Astropy installation files archive with various ISA support. Download the appropriate wheel file, then install with the command pip3 install /home/pi/file_name.whl.

Astropy comes with the full Anaconda install. With Miniconda, the recommended way to install Astropy is using the command conda install astropy.

Astropy Version History

Astropy 0.3.0 is what Miniconda 3.5.5 installs. This is a much earlier version than I would have expected. Astropy 0.3 was released in Nov 2013.

Astropy 0.4 was released in Jul 2014. Therefore Astropy 0.3 was the latest version when Miniconda 3.5.5 was released and is probably why Miniconda 3.5.5 installs with Astropy 0.3.

Astropy v1.2 requires Python v2.7 or later and Numpy 1.7.0 or later.

Astropy v1.3: “vectors and coordinates can be reshaped like arrays.”

Astropy v2.0.0 started to implement Python 3 but specifically says does not change functionality with Python 2. However, from 2.0.0 to 2.0.18, Python 2 was gradually phased out.

Astropy v3.0 is the first version that supports only Python 3.

I think I want Astropy v1.3 – unless it won’t run for some reason. Why does Miniconda 3.5.5 install Astropy 0.3.0? Was it the current Astropy at the release time? Answer: yes, it was. Do the newer Astropy versions require newer ISA? At some point, I got a “need ARMv7” error so probably.

However, also unexpectedly, it updates Python from 2.7.7 to 2.7.8. Python 2.7.8 was released in Jul 2014.

Astroplan

Python on Raspberry Pi

A lot of this is about Astropy and Astroplan because that’s what I was doing at the time. The main issue I remember is having to install the correct Raspberry Pi build of certain programs (I don’t remember which exactly now but the information is in here somewhere if I do again).

https://www.python.org/downloads

Raspberry Pi OS and Python versions support and description here.

The command pip3 is made for Python 3, so use it, not just pip.

  • Python 3.9.2 comes installed on the Raspberry Pi OS. Python 3.9.2 was released in Feb 2021.
  • Miniconda 3.5.5 installs Python 2.7.7. Python 2.7.7 was released in Jun 2014 (same month as Miniconda 3.5.5)
  • The Miniconda installation instructions specifically say you can leave Python installed do not remove it (see link below under Miniconda).
  • Astroplan uses the Python package Numpy. Use either the Linux command pip3 list, or python -c "import numpy; print(numpy.__version__)" to find the Numpy version installed.
    • I have Numpy 1.19.5. Is that because the legacy Miniconda installed it or because of the Python 3.9.2 installed on the Raspberry Pi OS? I think it’s the Python 3.9.2 from the OS.
    • Numpy downloads for Raspberry Pi here.
    • On my first test with Astroplan (and Astropy) I had a Numpy error that sent me to this link. The correction was sudo apt-get install libatlas-base-dev. I also updated Numpy with pip3 install numpy --upgrade and it upgraded to Numpy 1.21.5

Astropy on a Raspberry Pi Zero W

This is step-by-step how to install Astropy and Astroplan on a Raspberry Pi Zero W (1st gen, not the ‘2’).

Raspberry Pi OS download here along with imager here.

sudo passwd (change from default as desired for security)

sudo raspi-config

Set up location, time zone, language, keyboard, Wi-Fi, SSH. Turn off Bluetooth? How?

python --version

>> Python 3.9.2

sudo apt install python3-pip – for the Raspberry Pi, it is better to not use pip because it installs software not compiled for the Pi (the Pi Zero ISA is ARMv6l).

sudo apt install python3-numpy

sudo apt install python3-astropy

Note! Astropy installs this one. Not the rc2 or any of the other ones.

sudo apt install python3-pyerfa (installs with Astropy – I think)

sudo apt install python3-pyyaml (installs with Astropy – I think)

sudo apt install python3-packaging (installs with Astropy – I think)

sudo apt install python3-astroplan

sudo apt install python3-pytz (installs with Astroplan)

Other Astroplan options here.

sudo apt install python3-astroquery

sudo apt install python3-scipy

sudo apt install python3-kivy

sudo apt install fim

sudo apt install kivy

sudo apt install libmtdev1

sudo apt autoremove

Hardware

The Raspberry Pi Zero W is 32-bit and uses ARMv6 instead of the newer ARMv7. The [biggest? only?] difference is in how the processor handles floating point operations.

The Raspberry Pi Zero 2 W is 64-bit.

The Raspberry Pi OS version 11 – the latest version still – is 32-bit. A 64-bit Raspberry Pi OS is in development but not available yet.

To check the version of Raspberry Pi OS installed, cat /etc/os-release.

Python

Python comes already installed with the Raspberry Pi OS. To verify, type python --version. You could install if necessary with sudo apt install python3.8x.

sudo apt update is also a good command to run.

Python Flask App

Deploy Flask App with Apache

This required a lot of configuration to work with WSGI, but I finally made it work for the tlom project while working at Revi North and it was very stable in the end. However, Flask isn’t so great because you’re writing html with Python, then serving the html, which javascript is much better at.

sudo apt install libapache2-mod-wsgi-py3

sudo a2enmod wsgi

Disable apache2:

sudo update-rc.d apache2 disable

sudo update-rc.d apache2 enable

sudo service apache2 restart

sudo service apache2 start

sudo service apache2 stop

Serve a Flask App from Ubuntu Apache Server with WSGI
sudo apt-get install libapache2-mod-wsgi-py3

Put the files you have been using to dev in

/var/www/app_name

Python on Linux

Install a Local Python from Source

sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev

To install dependencies.

What the following does: download source code, unpack it, make directory ~/.localpython to install into, run the configuration file setting install going to install folder, compile, install compilation, create a virtualenv pointing to the install, switch to the virtualenv to use it:

mkdir ~/src

cd ~/src

$ wget http://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz

$ tar -zxvf Python-3.11.0.tgz

$ cd Python-3.11.0

$ mkdir ~/localpython3110

$ ./configure --prefix=$HOME/localpython3110 --enable-optimizations

https://realpython.com/installing-python/#how-to-build-python-from-source-code

$ make &&make altinstall

Set Up venv

$ ~/localpython3110/bin/python3.11 -m venv py3110_venv

$ source py3110_venv/bin/activate

$ sudo apt install python3-pip -y

$ pip install --upgrade pip

$ pip install tk pillow numpy astropy astroplan pandas pytz matplotlib scikit-learn

$ pip list

$ pip -V

$ which python

$ pip install --upgrade pip

$ pip freeze --local > requirements.txt

$ deactivate

$ rm -rf somename_env

$ pip install -r requirements.txt

Note the venv folder stores neither the Python installation nor your code for your project. It is only used to store version information about the Python installation used for your project.

virtualenv instead of venv

I ran into a not-so-obscure reason to use virtualenv instead of venv. If you ever want to serve a Flask app using Apache or some other production server, virtualenv creates a file called activate_this, which Apache can use to run the Flask app in the appropriate Python environment.

sudo apt install python3-pip -y

pip install virtualenv

python3 -m virtualenv py31012_virtualenv

source py31012_virtualenv/bin/activate

pip install --upgrade pip

Install Packages from Local Folder

pip download package1 package2 -d'~/src/python-packages'

pip install package1 package2 -f ~/src/python-packages --no-index

Python Path

To see the path to the current python installation:

python -c 'import os, sys; print(os.path.dirname(sys.executable))'

To see the path variable in Windows (readable format):

PS > $env:path -split ';'

Linux, Get Oriented

To login to a linux machine remotely:

ssh username@ipaddress

To see the version of Linux running:

cat /etc/os-release

printenv lists all environment variables

Print working directory:

pwd

Get IP address:

ifconfig or ifconfig | grep inet

See what ports are open:

netstat

List all users:

less /etc/passwd

List groups a user belongs to:

groups username or id username

List groups with their members:

getent group or getent group | grep searchsomething

To get the status, including rules being enforced, of the uncomplicated firewall:

sudo ufw status

To list all processes currently running;

ps aux | grep searchsomething

To find a particular file or directory from among all files:

sudo find / -name "searchsomething"

or for directory name search only:

sudo find / -type d -name "searchsomething"

To search for specific text within the files within the current directory:

grep -nr 'searchsomething*'

  • $ is the normal prompt for commands
  • # is the system administrator prompt
  • in the C shell, the prompt ends with %
  • > is used to send the output to a text file. >> is used to append the output to an existing text file without over-writing.
  • $VARIABLE_NAME is a variable
  • apt combines apt-get and apt-cache and it is newer. Use apt.
  • sudo apt update && sudo apt upgrade -y
    • To install Python packages, use apt only if you want to install directly on the machine, otherwise use pip. Pip installs modules slower, but installs the latest versions, and most importantly works within a virtualenv. In the special case of Raspberry Pi, use apt because it knows the unique processor architecture and installs the correct builds of modules.
  • script savedcommands.txt
  • A .sh file is an executable shell script. # to comment within
  • ./ is used to specify the current working directory especially when running something that could be the same as a system command.
  • nano is the basic user-friendly text editor.
  • To view $PATH, echo "${PATH//:/$'\n'}" or just echo $PATH
  • To edit $PATH for the current session, export PATH='/new/directory:$PATH'
  • > sends command output to a file. >> appends the output to a file without overwriting existing contents.
  • ls -al shows all files in directory including hidden
  • whatis is a brief explanation
  • man gives a manual
  • less is like cat, but one page at a time

Useful Linux Commands

At this point, you are using Linux. Either Raspberry Pi OS or Ubuntu are “flavors” of Linux. Having a list of basic commands is helpful:

Set up Firewall

sudo ufw allow OpenSSH

sudo ufw allow 22

sudo ufw allow 3306

sudo ufw default deny incoming

sudo ufw default allow outgoing

sudo ufw allow ssh

sudo ufw allow http or sudo ufw allow 80

sudo ufw allow https or sudo ufw allow 443

sudo ufw allow 'apache full'

sudo ufw show added

sudo ufw enable

Create Non-Root Super-User

This step appears complex and does not appear necessary especially this early in the process. Strictly speaking, it is indeed not necessary. You could skip this step and do everything as the root or default user that already exists. However, it is best to do this now because:

  • to do things in the right order
  • to highlight an important aspect of the Linux OS: that Linux is very user-specific and permissions-based. This makes Linux less intuitive at first but makes it secure enough to be accessed by many different anonymous people as a server without allowing hackers to access sensitive parts of the server.
  • to avoid inevitable frustration later. Using Linux you will see “permission denied” errors periodically throughout your experience and you are better off expecting and troubleshooting them than believing that Linux is just annoying. Permissions are built-in to Linux from the ground up and it’s best to work with it rather than try to ignore it.
  • Logging in as a non-root user is safer. For example, some installations of Ubuntu default to external root login disabled, which means for a remote server you would be locked out if this were set and you don’t have another user to login as.

sudo adduser new_username

usermod -aG sudo new_username

Change the password for the current user as desired with:

passwd

Grant all privileges to the user with the command

sudo visudo

and add a line in the /etc/sudoers file below the root user line: new_username ALL=(ALL:ALL)ALL

This only allows the user to give itself privileges. The user does not have all read/write privileges like the root itself. Log in as the new user through SSH.

Non-Root Super-User Gives Itself Read/Write Privileges

This sounds convoluted and it is when you are accustomed to dealing with desktop computers designed for convenience. Linux is designed for security.

Make a new group

sudo addgroup servermanager

and add the new user to the group

sudo adduser new_username servermanager

groups new_username

make the new group the owner of the required directories:

sudo chown -vR :servermanager /var/www/

sudo chown -vR :servermanager /etc/apache2/sites-available/

sudo chown -vR :servermanager /etc/apache2/sites-enabled

then modify the directory permission to be written by the owner group:

sudo chmod -vR g+w /var/www/ (add +x if you want to be able to develop in this directory)

sudo chmod -vR g+w /etc/apache2/sites-available

sudo chmod -vR g+w /etc/apache2/sites-enabled

(Useful Users and Permissions Commands)

Linux has a group and user structure to manage permissions and it is very useful to be able to view the current state:

List all users in the system:

cat /etc/passwd

List all groups on the system:

cat etc/group or less etc/group

or

getent group

for all members of a single group:

getent group group_name

check ownership of a directory, for example:

ls -ld /var/www/

check ownership of a file:

ls -l /var/www/

Find all the files owned by a particular user (may take some time):

sudo find / -user username

Change the active group for the session, possibly not:

newgrp servermanager

delete a group:

sudo groupdel group_name

delete a user (-r removes the user’s directory and mail spool):

sudo userdel -r username

search “linux octal permissions” to understand the numbering system.

Show all currently logged in users on a system:

w

Will Direct Sun Damage a Camera Sensor?

Disclaimer: I did this with a Sony a7iii, which is mirrorless, no direct sun to my eyes and I had the screen pointed up so I didn’t look at the sun.

I wanted to put some numbers to this question, so I put on an ND8 filter (3 stops) and shot at 70mm, F36, ISO100. I took a picture of the bright sky next to the sun without direct sun as a baseline for “the brightest thing a camera is really designed to see.” Then I spot-metered directly on the afternoon sun in the center of the photo. The auto-shutter speed increased from 1/30 to 1/8000, so ~256x increase, or 8 stops. The sun was reasonably visible in the photo, but still bright (of course everything around it is black in the photo). I would say it was somewhat close to “properly exposed,” whatever that means in this case. 256x as bright as the bright sky is BRIGHT.

Bright Sky Near the Sun:
Direct sun with shutter speed 8 stops faster, so 1/256 as much light allowed in:

Notice the sun itself is still white.

I think there is not a good answer to “will direct sun damage my sensor?” because the best solution is to NOT have direct sun in the photo. 256x as bright as the bright sky seems like enough to damage the sensor, at least a few pixels, and it just doesn’t make for a good photo anyway – except sunrise or sunset of course with the beautiful filtering of the atmosphere.

For time lapses, I am going to start using interesting shadows to show sun movement instead of trying to figure out how to include the sun itself.

I don’t think the focal length actually matters much because the focal length just makes the sun bigger, not brighter per pixel. It only takes a few burned pixels for the sensor to be ruined so even if the sun is small – as it is with a wide-angle lens – the sun could damage some pixels if the aperture is too wide and/or not enough filter.

Bottom line, I think what actually matters for damage is:

  • aperture
  • filter (sunglasses for your camera)
  • brightness of the sun (noon vs sunset)
  • time spent with sun on the sensor.

Book Club Notes – Patriots by James Wesley, Rawles

James Wesley, Rawles
  • Blogger and journalist.
  • Supports “citizen journalism,” which I would like to learn more about.
  • In his words: https://survivalblog.com/biographies/
  • Notice his list of memberships. Good list to consider.
Book Notes
  • A previous title for the novel was The Gray Nineties
  • The series has a Wikipedia article.
  • I’m not very far in to the book still.
  • So far, my initial impression is it’s better-written than Unintended Consequences. (Actually I don’t think the author would want to be compared to that book).
  • Voting people in or out isn’t just about utility, it’s about morale.
  • If I were Matt and Chase, I would have left the country and the hemisphere. I would find a way to publicize my side of the story from a distance. Public opinion matters. Why is media always excluded from the plan? You’re already famous can’t go back from that.
  • “That winter, they ate the golden retrievers” dogs and dog breeds survive based on what people need. The idea that even a wolf is free or independent of humans is only relative to our dependence on humans. Every animal on Earth now survives at the behest of humans, it just doesn’t appear so direct.
On Prepping in General
  • 99% of world’s resources are controlled by humans
  • Retiring is the closest people typically actually come to this scenario because the most difficult thing about surviving long-term IMO would be adjusting to caring about different things. Complete routine adjustment. Completely different source of self-worth.

Time v3 Reading List

Some great reading about timekeeping in the Industrial Revolution. Here are some examples:

The Clocks are Telling Lies by Scott Alan Johnston. Centers around the International Meridian Conference. Talks a lot about the distinction between scientific professionals’ and amateurs’ perception of timekeeping.

Time, Work-Discipline, and Industrial Capitalism by E. P. Thompson. Discusses the transition from natural time to using clocks to regulate labor.

Greenwich Time and the Longitude by Derek Howse. Recommended by Bjorn Kartomten.

Delaware Ohio Podcast Episode 1

Download the episode 1 mp3 here.

On your phone, long-click then select “download mp3 file” or “download link” to download to your phone and listen with any mp3 player including Spotify for example.

It is a simple mp3 file. Recommend using the VLC Media Player app to listen to the mp3 on your phone. With VLC media player you can “long-touch” the rewind button to rewind 20 seconds if you miss something, which I use a lot when listening to podcasts.

On computer, right-click to download.

Summary

Delaware resident and host Nathan Ruffing interviews City Councilman Drew Farrell for the very first episode. We talk Delaware City Council issues, podcasting in general, decide Drew is also a host not just a guest in the future, work out the nerves a little bit, and solicit suggestions for where the podcast should go next. One thing is certain: there should be a Delaware Ohio Podcast. The question is, “Where should the podcast go next?”

Let us know with the form on the podcast main page here:

Delaware Ohio Podcast main page, click here.