Skip to content

Commit

Permalink
Merge pull request #2 from ssc-ai/r0.13.1
Browse files Browse the repository at this point in the history
Commit version v0.13.1.
  • Loading branch information
mixxen authored Mar 15, 2023
2 parents b541282 + f6074f5 commit 4a9bdc8
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 27 deletions.
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
History
=======

0.13.1
---------------------

* Add argument to set folder name in `gen_multi`.
* Add environment variable, `SATSIM_SKYFIELD_LOAD_DIR`, to specify location of Skyfield ephemeris files.
* Fix incorrect CZML output when image renderer is off.


0.13.0
---------------------

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ install: clean ## install the package to the active python3's site-packages
@echo IMPORTANT: You may need to close and restart your shell after running "make install".

docker: docs dist
docker build -t satsim:0.13.0 -t satsim:latest -f docker/ubuntu20.04_cuda11.2_py3.8.dockerfile .
docker build -t satsim:0.13.1 -t satsim:latest -f docker/ubuntu20.04_cuda11.2_py3.8.dockerfile .

dind:
docker run --rm -it -v $(CURDIR):/workspace/ -w /workspace python:3.8-bullseye ./build.sh
docker build -t satsim:0.13.0 -t satsim:latest -f docker/ubuntu20.04_cuda11.2_py3.8.dockerfile .
docker build -t satsim:0.13.1 -t satsim:latest -f docker/ubuntu20.04_cuda11.2_py3.8.dockerfile .

uninstall: clean
cat .install.log | xargs rm -rf
12 changes: 6 additions & 6 deletions docker/ubuntu20.04_cuda11.2_py3.8.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
RUN pip3 install --no-cache-dir --upgrade pip setuptools

# copy and install satsim wheel file
ENV SATSIM_VERSION='0.13.0'
COPY dist/satsim-0.13.0-py2.py3-none-any.whl /tmp
ENV SATSIM_VERSION='0.13.1'
COPY dist/satsim-0.13.1-py2.py3-none-any.whl /tmp

# install python prereqs and satsim
RUN pip3 --no-cache-dir install \
imageio==2.15.0 \
tensorflow~=2.8.0 \
tensorflow-addons~=0.16.1 \
tmp/satsim-0.13.0-py2.py3-none-any.whl
tmp/satsim-0.13.1-py2.py3-none-any.whl

RUN pip3 --no-cache-dir install \
jupyterlab \
scikit-learn \
virtualenv

# copy and install satsim wheel file
ENV SATSIM_VERSION='0.13.0'
COPY dist/satsim-0.13.0-py2.py3-none-any.whl /tmp
RUN pip3 install tmp/satsim-0.13.0-py2.py3-none-any.whl
ENV SATSIM_VERSION='0.13.1'
COPY dist/satsim-0.13.1-py2.py3-none-any.whl /tmp
RUN pip3 install tmp/satsim-0.13.1-py2.py3-none-any.whl

RUN mkdir /workspace
WORKDIR /workspace
Expand Down
2 changes: 1 addition & 1 deletion satsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__author__ = """Alex Cabello"""
__email__ = '[email protected]'
__version__ = '0.13.0'
__version__ = '0.13.1'

from .satsim import gen_images, gen_multi, image_generator
from .config import load_json, load_yaml
12 changes: 10 additions & 2 deletions satsim/geometry/astrometric.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
"""Tests for `satsim.geometry.astrometric` package."""
import os
from functools import lru_cache

import numpy as np
from skyfield.api import Topos, load, Star, Angle
from pygc import great_circle
from skyfield.api import Topos, Star, Angle
from skyfield.relativity import add_aberration, add_deflection
from skyfield.earthlib import compute_limb_angle
from skyfield.positionlib import Apparent
from pygc import great_circle

if 'SATSIM_SKYFIELD_LOAD_DIR' in os.environ:
from skyfield.api import Loader
load = Loader(os.environ['SATSIM_SKYFIELD_LOAD_DIR'])
else:
from skyfield.api import load

from satsim.geometry.wcs import get_min_max_ra_dec, get_wcs


SATSIM_EARTH = None
SATSIM_MOON = None
SATSIM_SUN = None
Expand Down
10 changes: 6 additions & 4 deletions satsim/io/image.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import division, print_function, absolute_import

from os import listdir
from os.path import isfile, join, splitext
from os.path import isfile, join, splitext, exists

import numpy as np
import matplotlib.image as mpimg
Expand Down Expand Up @@ -56,8 +56,10 @@ def save_apng(dirname, filename):
dirname: `string`, directory containing image files to combine.
filename: `string`, file name of the animated PNG.
"""
from apng import APNG
if exists(dirname):

files = [join(dirname, f) for f in sorted(listdir(dirname)) if isfile(join(dirname, f)) and (splitext(f)[1] == '.png' or splitext(f)[1] == '.jpg')]
from apng import APNG

APNG.from_files(files, delay=100).save(join(dirname, filename))
files = [join(dirname, f) for f in sorted(listdir(dirname)) if isfile(join(dirname, f)) and (splitext(f)[1] == '.png' or splitext(f)[1] == '.jpg')]

APNG.from_files(files, delay=100).save(join(dirname, filename))
30 changes: 20 additions & 10 deletions satsim/satsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
logger = logging.getLogger(__name__)


def gen_multi(ssp, eager=True, output_dir='./', input_dir='./', device=None, memory=None, pid=0, output_debug=False):
def gen_multi(ssp, eager=True, output_dir='./', input_dir='./', device=None, memory=None, pid=0, output_debug=False, folder_name=None):
"""Generates multiple sets of images. Number of sets is based on the
parameters `ssp['sim']['samples']`.
Expand All @@ -64,6 +64,7 @@ def gen_multi(ssp, eager=True, output_dir='./', input_dir='./', device=None, mem
device: `array`, array of GPU device IDs to enable. If `None`, enable all.
pid: `int`, an ID to associate this instance to.
output_debug: `boolean`, output intermediate debug files.
folder_name: `str`, Optional name for folder to save files to.
"""
if(eager):
configure_eager()
Expand All @@ -87,7 +88,7 @@ def gen_multi(ssp, eager=True, output_dir='./', input_dir='./', device=None, mem
tssp, issp = transform(copy.deepcopy(ssp), input_dir, with_debug=True)

# run the transformed parameters
dir_name = gen_images(tssp, eager, output_dir, set_num, queue=queue, output_debug=output_debug)
dir_name = gen_images(tssp, eager, output_dir, set_num, queue=queue, output_debug=output_debug, set_name=folder_name)

# save intermediate transforms
save_debug(issp, dir_name)
Expand Down Expand Up @@ -133,6 +134,9 @@ def gen_images(ssp, eager=True, output_dir='./', sample_num=0, output_debug=Fals
dir_name = os.path.join(output_dir, dt.isoformat().replace(':','-'))
set_name = 'sat_{:05d}'.format(sample_num)

else:
dir_name = os.path.join(output_dir, set_name)

# make output dirs
os.makedirs(dir_name, exist_ok=True)
dir_debug = os.path.join(dir_name,'Debug')
Expand Down Expand Up @@ -181,7 +185,6 @@ def f():
return None
queue.task(f, {}, tag=dir_name)
logger.debug('Render mode off. Skipping frame generation.')
break

# write movie
def wait_and_run():
Expand Down Expand Up @@ -650,6 +653,10 @@ def gen_objects(obs, t_start, t_end):
ts_epoch = time.utc_from_list_or_scalar(o['epoch'], default_t=tt)
obs_cache[i] = [create_twobody(np.array(o['position']) * u.km, np.array(o['velocity']) * u.km / u.s, ts_epoch)]

# skip rest if not rendering images
if ssp['sim']['mode'] == 'none':
continue

o_offset = [0.0, 0.0]
if 'offset' in o:
o_offset = [o['offset'][0] * h_fpa_os, o['offset'][1] * w_fpa_os]
Expand Down Expand Up @@ -740,6 +747,16 @@ def gen_objects(obs, t_start, t_end):
t_start_star = t_start
t_end_star = t_end

# if image rendering is disabled, then propagate objects and return
if ssp['sim']['mode'] == 'none':
r_obs_os, c_obs_os, pe_obs_os, obs_os_pix, obs_model = gen_objects(obs, t_start, t_end)
logger.debug('Number of objects {}.'.format(len(obs_os_pix)))

if with_meta:
yield None, frame_num, None, None, None, None, None, None, None, None, obs_cache
else:
yield None

# refresh catalog stars
# TODO should save stars and transform to FPA again on every frame
if (star_mode == 'sstr7' or star_mode == 'csv') and (ssp['sim']['star_catalog_query_mode'] == 'frame' or frame_num == 0):
Expand Down Expand Up @@ -774,13 +791,6 @@ def gen_objects(obs, t_start, t_end):
c_obs_os = tf.cast(c_obs_os, tf.float32)
pe_obs_os = tf.cast(pe_obs_os, tf.float32)

# TODO should refactor this
if ssp['sim']['mode'] == 'none':
if with_meta:
yield None, 0, None, None, None, None, None, None, None, None, obs_cache
else:
yield None

# augment TODO abstract this
if pydash.objects.has(ssp, 'augment.fpa.psf'):
psf_os_curr = ssp['augment']['fpa']['psf'](psf_os)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.13.0
current_version = 0.13.1
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/ssc-ai/satsim',
version='0.13.0',
version='0.13.1',
zip_safe=False,
)

0 comments on commit 4a9bdc8

Please sign in to comment.