Closed solresol closed 8 months ago
None
)[!TIP] I can email you next time I complete a pull request if you set up your email here!
The sandbox appears to be unavailable or down.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
moonpos_catchup.py
✓ https://github.com/solresol/lunar-astronomy/commit/bb0b7bc64352f4010a3b507eac37763862a873c0 Edit
Create moonpos_catchup.py with contents:
• Start by importing the necessary libraries at the top of the file. These will include `argparse`, `configparser`, `psycopg2`, and the `calculate_moon_position_and_phase` function from `moonpos.py`.
• Next, set up the argument parser to accept the same command-line arguments as `catchup_sunpos.py`. These are `--config`, `--progress`, and `--skip-refresh`.
• Read the configuration settings from the `config.ini` file using `configparser`. These settings will include the API key, location coordinates, and database connection details.
• Establish a connection to the PostgreSQL database using `psycopg2` and the connection details from the configuration settings.
• If the `--skip-refresh` argument is not provided, execute a SQL command to refresh the `production_rounded_off` materialized view.
• Execute a SQL query to select the `when_recorded_rounded` column from the `missing_moonpositions` view, ordered by the `gmt_when` alias.
• Iterate over the rows returned by the query. For each row, call the `calculate_moon_position_and_phase` function with the `gmt_when` and location coordinates to calculate the moon's altitude, azimuth, and phase.
• For each calculated moon position, execute a SQL command to insert a new record into the `moon_position` table with the `when_recorded`, `altitude`, `azimuth`, and `phase` values.
• Commit the database transaction after each insert to ensure the changes are saved.
I have finished reviewing the code for completeness. I did not find errors for sweep/create_moonpos_catchuppy
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
Details
Create moonpos_catchup.py. This program queries the postgresql database and looks at the missing_moonpositions view to get dates where we don't have a moon position caclulcated. It then uses this function from
moonpos.py
on each of those dates...def calculate_moon_position_and_phase(date_time, latitude, longitude):
which does
return moon.alt, moon.az, moon.phase
It then populates the database table
moon_position
Here is some psql output so that you know the column names:
Here is the catchup_sunpos.py program that I wrote earlier. catchup_moonpos.py will be very similar:
Checklist
- [X] Create `moonpos_catchup.py` ✓ https://github.com/solresol/lunar-astronomy/commit/bb0b7bc64352f4010a3b507eac37763862a873c0 [Edit](https://github.com/solresol/lunar-astronomy/edit/sweep/create_moonpos_catchuppy/moonpos_catchup.py)