Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustments to SOIT implementation #96

Merged
merged 6 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ To run SOIT manually :
- [ ] ` export SPACEPSWD=<password>`
3. Update inputs and run the following:
```bash
docker run --env SPACEUSER --env SPACEPSWD --mount type=bind,source=<your_desired_output_dir>,target=/tmp brownccv/ \
icefloetracker-fetchdata:main \
python3 /usr/local/bin/pass_time_cylc.py --startdate <YYYY-MM-DD> --enddate <YYYY-MM-DD> --csvoutpath /tmp --centroid_x <input_centroid_x> --centroid_y $<input_centroid_y> --SPACEUSER $SPACEUSER --SPACEPSWD $SPACEPSWD
docker run --env SPACEUSER --env SPACEPSWD --mount type=bind,source=<your_desired_output_dir>,target=/tmp brownccv/icefloetracker-fetchdata:main \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra space in line 23 was giving me an uninformative error from docker "docker: invalid reference format". Deleting the space between brownccv/ and icefloetracker-fetchdata:main made it so it would run.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

python3 /usr/local/bin/pass_time_cylc.py --startdate <YYYY-MM-DD> --enddate <YYYY-MM-DD> --csvoutpath /tmp --centroid_lat <input_centroid_lat> --centroid_lon <input_centroid_lon> --SPACEUSER $SPACEUSER --SPACEPSWD $SPACEPSWD
```
* be sure to replace `source`, `startdate`, `enddate`, `centroid_x`, and `centroid_y` with your desired inputs
* be sure to replace `source`, `startdate`, `enddate`, `centroid_lat`, and `centroid_lon` with your desired inputs
* csvoutpath must remain as `/tmp` to bind the Docker container output path with your desired local path

**Note:** The `pass_time_cylc.py` script in this project can be adapted to include additional satellites available in the [space-track.org](https://www.space-track.org/) repository.
**Note:** The `pass_time_cylc.py` script in this project can be adapted to include additional satellites available in the [space-track.org](https://www.space-track.org/) repository. If you have `numpy` and `skyfield` installed in a local `conda` environment, you can run `pass_time_cylc.py` from the directory where you installed the Ice Floe Tracker Pipeline:
```python3 workflow/scripts/pass_time_cylc.py --startdate <YYYY-MM-DD> --enddate <YYYY-MM-DD> --csvoutpath <save_directory> --centroid_x <input_centroid_x> --centroid_y <input_centroid_y> --SPACEUSER $SPACEUSER --SPACEPSWD $SPACEPSWD```

## Fetching data from NASA Worldview

Expand Down
29 changes: 14 additions & 15 deletions workflow/scripts/pass_time_cylc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,18 @@ def __init___(self, args):


def get_passtimes(
startdate, enddate, csvoutpath, centroid_x, centroid_y, SPACEUSER, SPACEPSWD
startdate, enddate, csvoutpath, centroid_lat, centroid_lon, SPACEUSER, SPACEPSWD
):
centroidx = centroid_x
centroidy = centroid_y
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for changing variable names centroid_x to centroidx to lat in the original script? Why not use lat all the way through? For now I switched centroid_x to centroid_lat to make it clear that providing an x value would break things.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

centroid_x and centroid_y are the variable names used in the Cylc pipeline so I think I just had reset them during dev to keep track of the inputs. We'll probably just have to update the Cylc templates after this PR is merged.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I thought about updating those but didn't want to break the Docker stuff.

configUsr = SPACEUSER
configPwd = SPACEPSWD
siteCred = {"identity": configUsr, "password": configPwd}
end_date = datetime.datetime.strptime(enddate, "%Y-%m-%d").strftime("%m-%d-%Y").split("-")
start_date = datetime.datetime.strptime(startdate, "%Y-%m-%d").strftime("%m-%d-%Y").split("-")
lat = int(centroidx)
long = int(centroidy)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change in variable names is just personal preference. I think long looks weird. The use of int is more troubling. Not only do we force the loss of accuracy on the order of 100 km, casting to int means we're not even going for the nearest integer. The wgs84.latlon function doesn't require integers -- the example on the skyfield API has decimal degrees, and the header for pass_time_cylc.py says that decimal degrees are accepted.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember if that's just how the original script was or if there was a reason we had to use int(). Did you test it with float() just to verify that the script runs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, it ran perfectly fine with float lat/lon on my machine

lat = float(centroid_lat)
lon = float(centroid_lon)
print(f"Outpath {csvoutpath}")
print(f"Timeframe starts on {start_date}, and ends on {end_date}")
print(f"Centroid (x, y): ({centroidx}, {centroidy})")
print(f"Coordinates (x, y): ({centroid_lat}, {centroid_lon})")

end_date = getNextDay(end_date)

Expand Down Expand Up @@ -100,7 +98,7 @@ def get_passtimes(
ts = load.timescale()

# Specify area of interest.
aoi = wgs84.latlon(lat, long)
aoi = wgs84.latlon(lat, lon)

# Define today and tomorrow.
today = start_date
Expand Down Expand Up @@ -375,7 +373,7 @@ def get_passtimes(
today = getNextDay(today)
tomorrow = getNextDay(today)

csvwrite(start_date, end_date, lat, long, rows, csvoutpath)
csvwrite(start_date, end_date, lat, lon, rows, csvoutpath)


# Write CSV of all pass information.
Expand Down Expand Up @@ -459,17 +457,18 @@ def main():
help="End date in format YYYY-MM-DD",
)
parser.add_argument(
"--centroid_x",
"-x",
metavar="centroid_x",
"--centroid_lat",
"-lat",
metavar="centroid_lat",
type=str,
help="x-coordinate of bounding box centroid",
help="latitude of bounding box centroid",
)
parser.add_argument(
"--centroid_y",
"-y",
"--centroid_lon",
"-lon",
metavar="centroid_lon",
type=str,
help="y-coordinate of bounding box centroid",
help="longitude of bounding box centroid",
)
parser.add_argument(
"--csvoutpath",
Expand Down
Loading