Skip to content

Commit

Permalink
Umbriel
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffenhir committed Apr 17, 2024
2 parents 76a4be8 + 309a224 commit f124b54
Show file tree
Hide file tree
Showing 44 changed files with 2,499 additions and 698 deletions.
97 changes: 56 additions & 41 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ env:
ai_s3_access_key: ${{ secrets.AI_S3_ACCESS_KEY }}
ai_s3_secret_key: ${{ secrets.AI_S3_SECRET_KEY }}
ai_s3_bucket_name: ${{ secrets.AI_S3_BUCKET_NAME }}
ai_s3_bge_bucket_name: ${{ secrets.AI_S3_BGE_BUCKET_NAME }}
ai_s3_denoise_bucket_name: ${{ secrets.AI_S3_DENOISE_BUCKET_NAME }}

on:
push:
Expand All @@ -13,38 +15,41 @@ on:

jobs:

build-linux-deb:
runs-on: ubuntu-20.04
steps:
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: checkout repository
uses: actions/checkout@v3
- name: configure ai s3 secrets
run: |
echo "endpoint = \"$ai_s3_endpoint\"" >> ./graxpert/s3_secrets.py && \
echo "ro_access_key = \"$ai_s3_access_key\"" >> ./graxpert/s3_secrets.py && \
echo "ro_secret_key = \"$ai_s3_secret_key\"" >> ./graxpert/s3_secrets.py && \
echo "bucket_name = \"$ai_s3_bucket_name\"" >> ./graxpert/s3_secrets.py
- name: install dependencies
run: |
sudo apt install alien -y && \
pip install "cx_freeze>=6.16.0.dev" && \
pip install -r requirements.txt
- name: patch version
run: |
chmod u+x ./releng/patch_version.sh && \
./releng/patch_version.sh
- name: create GraXpert-linux bundle
run: python ./setup.py bdist_deb
- name: store artifacts
uses: actions/upload-artifact@v2
with:
name: graxpert_${{github.ref_name}}-1_amd64.deb
path: ./dist/graxpert_${{github.ref_name}}-1_amd64.deb
retention-days: 5
# build-linux-deb:
# runs-on: ubuntu-20.04
# steps:
# - name: setup python
# uses: actions/setup-python@v2
# with:
# python-version: '3.10'
# - name: checkout repository
# uses: actions/checkout@v3
# - name: configure ai s3 secrets
# run: |
# echo "endpoint = \"$ai_s3_endpoint\"" >> ./graxpert/s3_secrets.py && \
# echo "ro_access_key = \"$ai_s3_access_key\"" >> ./graxpert/s3_secrets.py && \
# echo "ro_secret_key = \"$ai_s3_secret_key\"" >> ./graxpert/s3_secrets.py && \
# echo "bucket_name = \"$ai_s3_bucket_name\"" >> ./graxpert/s3_secrets.py && \
# echo "bge_bucket_name = \"$ai_s3_bge_bucket_name\"" >> ./graxpert/s3_secrets.py && \
# echo "denoise_bucket_name = \"$ai_s3_denoise_bucket_name\"" >> ./graxpert/s3_secrets.py
# - name: install dependencies
# run: |
# sudo apt install alien -y && \
# pip install "cx_freeze" && \
# pip install onnxruntime-gpu && \
# pip install -r requirements.txt
# - name: patch version
# run: |
# chmod u+x ./releng/patch_version.sh && \
# ./releng/patch_version.sh
# - name: create GraXpert-linux bundle
# run: python ./setup.py bdist_deb
# - name: store artifacts
# uses: actions/upload-artifact@v2
# with:
# name: graxpert_${{github.ref_name}}-1_amd64.deb
# path: ./dist/graxpert_${{github.ref_name}}-1_amd64.deb
# retention-days: 5

build-linux-zip:
runs-on: ubuntu-20.04
Expand All @@ -60,10 +65,13 @@ jobs:
echo "endpoint = \"$ai_s3_endpoint\"" >> ./graxpert/s3_secrets.py && \
echo "ro_access_key = \"$ai_s3_access_key\"" >> ./graxpert/s3_secrets.py && \
echo "ro_secret_key = \"$ai_s3_secret_key\"" >> ./graxpert/s3_secrets.py && \
echo "bucket_name = \"$ai_s3_bucket_name\"" >> ./graxpert/s3_secrets.py
echo "bucket_name = \"$ai_s3_bucket_name\"" >> ./graxpert/s3_secrets.py && \
echo "bge_bucket_name = \"$ai_s3_bge_bucket_name\"" >> ./graxpert/s3_secrets.py && \
echo "denoise_bucket_name = \"$ai_s3_denoise_bucket_name\"" >> ./graxpert/s3_secrets.py
- name: install dependencies
run: |
pip install setuptools wheel cx_freeze && \
pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ && \
pip install -r requirements.txt
- name: patch version
run: |
Expand Down Expand Up @@ -97,10 +105,13 @@ jobs:
"endpoint = `"$env:ai_s3_endpoint`"" | Out-File -Append .\graxpert\s3_secrets.py ; `
"ro_access_key = `"$env:ai_s3_access_key`"" | Out-File -Append .\graxpert\s3_secrets.py ; `
"ro_secret_key = `"$env:ai_s3_secret_key`"" | Out-File -Append .\graxpert\s3_secrets.py ; `
"bucket_name = `"$env:ai_s3_bucket_name`"" | Out-File -Append .\graxpert\s3_secrets.py
"bucket_name = `"$env:ai_s3_bucket_name`"" | Out-File -Append .\graxpert\s3_secrets.py ; `
"bge_bucket_name = `"$env:ai_s3_bge_bucket_name`"" | Out-File -Append .\graxpert\s3_secrets.py ; `
"denoise_bucket_name = `"$env:ai_s3_denoise_bucket_name`"" | Out-File -Append .\graxpert\s3_secrets.py
- name: install dependencies
run: |
pip install setuptools wheel cx_freeze; `
pip install onnxruntime-directml; `
pip install -r requirements.txt
- name: patch version
run: ./releng/patch_version.ps1
Expand All @@ -123,7 +134,9 @@ jobs:
echo "endpoint = \"$ai_s3_endpoint\"" >> ./graxpert/s3_secrets.py && \
echo "ro_access_key = \"$ai_s3_access_key\"" >> ./graxpert/s3_secrets.py && \
echo "ro_secret_key = \"$ai_s3_secret_key\"" >> ./graxpert/s3_secrets.py && \
echo "bucket_name = \"$ai_s3_bucket_name\"" >> ./graxpert/s3_secrets.py
echo "bucket_name = \"$ai_s3_bucket_name\"" >> ./graxpert/s3_secrets.py && \
echo "bge_bucket_name = \"$ai_s3_bge_bucket_name\"" >> ./graxpert/s3_secrets.py && \
echo "denoise_bucket_name = \"$ai_s3_denoise_bucket_name\"" >> ./graxpert/s3_secrets.py
# github actions overwrites brew's python. Force it to reassert itself, by running in a separate step.
- name: unbreak python in github actions
run: |
Expand All @@ -134,6 +147,7 @@ jobs:
run: |
brew install python-tk && \
pip3 install setuptools wheel pyinstaller && \
pip3 install onnxruntime && \
pip3 install -r requirements.txt
- name: patch version
run: |
Expand Down Expand Up @@ -166,12 +180,13 @@ jobs:

release:
runs-on: ubuntu-latest
needs: [build-linux-deb, build-linux-zip, build-windows, build-macos-x86_64]
# needs: [build-linux-deb, build-linux-zip, build-windows, build-macos-x86_64]
needs: [build-linux-zip, build-windows, build-macos-x86_64]
steps:
- name: download linux deb
uses: actions/download-artifact@v2
with:
name: graxpert_${{github.ref_name}}-1_amd64.deb
# - name: download linux deb
# uses: actions/download-artifact@v2
# with:
# name: graxpert_${{github.ref_name}}-1_amd64.deb
- name: download linux zip
uses: actions/download-artifact@v2
with:
Expand All @@ -188,7 +203,7 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: |
graxpert_${{github.ref_name}}-1_amd64.deb
GraXpert-linux.zip
GraXpert-${{github.ref_name}}-win64.msi
GraXpert-macos-x86_64.dmg
# graxpert_${{github.ref_name}}-1_amd64.deb
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"configurations": [
{
"name": "Run GraXpert",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "graxpert.main",
"justMyCode": true
"justMyCode": true,
}
]
}
8 changes: 7 additions & 1 deletion GraXpert-macos-x86_64.spec
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import copy_metadata


block_cipher = None


datas = []
datas += [('./img/*', './img/'), ('./graxpert-dark-blue.json', './')]
datas += copy_metadata('xisf')


a = Analysis(['./graxpert/main.py'],
pathex=[],
binaries=[],
datas=[('./img/*', './img/'), ('./graxpert-dark-blue.json', './')],
datas=datas,
hiddenimports=['PIL._tkinter_finder', 'tkinter'],
hookspath=['./releng'],
hooksconfig={},
Expand Down
84 changes: 84 additions & 0 deletions graxpert/AstroImageRepository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from graxpert.astroimage import AstroImage
from graxpert.stretch import StretchParameters, stretch_all, calculate_mtf_stretch_parameters_for_image
from typing import Dict

class AstroImageRepository:
images: Dict = {"Original": None, "Gradient-Corrected": None, "Background": None, "Denoised": None}

def set(self, type:str, image:AstroImage):
self.images[type] = image

def get(self, type:str):
return self.images[type]

def stretch_all(self, stretch_params:StretchParameters, saturation:float):

if self.get("Original") is None:
return

stretches = []

if not stretch_params.do_stretch:
for key, image in self.images.items():
if image is not None:
stretches.append(image.img_array)

else:

all_image_arrays = []
all_mtf_stretch_params = []

all_image_arrays.append(self.get("Original").img_array)
all_mtf_stretch_params.append(calculate_mtf_stretch_parameters_for_image(stretch_params, self.get("Original").img_array))

if self.get("Gradient-Corrected") is not None and self.get("Background") is not None:
all_image_arrays.append(self.get("Gradient-Corrected").img_array)
all_mtf_stretch_params.append(calculate_mtf_stretch_parameters_for_image(stretch_params, self.get("Gradient-Corrected").img_array))

all_image_arrays.append(self.get("Background").img_array)
all_mtf_stretch_params.append(all_mtf_stretch_params[0])


if self.get("Denoised") is not None and self.get("Gradient-Corrected") is None:
all_image_arrays.append(self.get("Denoised").img_array)
all_mtf_stretch_params.append(all_mtf_stretch_params[0])

elif self.get("Denoised") is not None and self.get("Gradient-Corrected") is not None:
all_image_arrays.append(self.get("Denoised").img_array)
all_mtf_stretch_params.append(all_mtf_stretch_params[1])


stretches = stretch_all(all_image_arrays, all_mtf_stretch_params)


i = 0
for key, image in self.images.items():
if image is not None:
image.update_display_from_array(stretches[i], saturation)
i = i + 1

def crop_all(self, start_x:float, end_x:float, start_y:float, end_y:float):
for key, astroimg in self.images.items():
if astroimg is not None:
astroimg.crop(start_x, end_x, start_y, end_y)

def update_saturation(self, saturation):
for key, value in self.images.items():
if (value is not None):
value.update_saturation(saturation)

def reset(self):
for key, value in self.images.items():
self.images[key] = None

def display_options(self):
display_options = []

for key, value in self.images.items():
if (self.images[key] is not None):
display_options.append(key)

return display_options



Loading

0 comments on commit f124b54

Please sign in to comment.