Skip to content
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
3 changes: 3 additions & 0 deletions profiling/performance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import cProfile

cProfile.run("import vstarstack.tool.image")
17 changes: 9 additions & 8 deletions src/vstarstack/tool/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@
import os
import math
import numpy as np
import imageio
from astropy.io import fits

import matplotlib.pyplot as plt

from vstarstack.library.image_process.border import border
from vstarstack.library.image_process.cut import cut
import vstarstack.library.data
import vstarstack.tool.common

import vstarstack.tool.usage
import vstarstack.tool.cfg

Expand Down Expand Up @@ -97,6 +89,8 @@ def _make_frames(dataframe, channels):


def _show(_project, argv):
import matplotlib.pyplot as plt
import vstarstack.library.data
path = argv[0]
channels = None
if len(argv[1:]) > 0:
Expand Down Expand Up @@ -130,6 +124,7 @@ def _show(_project, argv):


def _convert(_project, argv):
import vstarstack.library.data
path = argv[0]
out = argv[1]

Expand All @@ -149,6 +144,7 @@ def _convert(_project, argv):
ext = ext[1:]

if ext == "fits":
from astropy.io import fits
vstarstack.tool.common.check_dir_exists(path)
for channel, img in frames.items():
if NORM:
Expand All @@ -160,6 +156,7 @@ def _convert(_project, argv):
fname = os.path.join(path, f"{name}_{channel}.{ext}")
hdul.writeto(fname)
else:
import imageio
for channels, img in frames.items():
if nch > 1:
fname = os.path.join(path, f"{name}_{channels}.{ext}")
Expand All @@ -176,6 +173,8 @@ def _convert(_project, argv):
imageio.imwrite(fname, img)

def _cut(_project, argv):
import vstarstack.library.data
from vstarstack.library.image_process.cut import cut
path = argv[0]
left = int(argv[1])
top = int(argv[2])
Expand All @@ -189,6 +188,7 @@ def _cut(_project, argv):
result.store(out)

def _rename_channel(_project, argv):
import vstarstack.library.data
name = argv[0]
channel = argv[1]
target = argv[2]
Expand All @@ -199,6 +199,7 @@ def _rename_channel(_project, argv):
dataframe.store(name)

def _exposures(_project, argv):
import vstarstack.library.data
fname = argv[0]
dataframe = vstarstack.library.data.DataFrame.load(fname)
channels = dataframe.get_channels()
Expand Down
1 change: 1 addition & 0 deletions src/vstarstack/tool/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def run(project, argv, base, commands, message=None):
new_base = base + " " + cmd
else:
new_base = cmd
print("Load module: %s" % submodule)
loaded_submodule = importlib.import_module(submodule)
run(project, argv[1:], new_base, loaded_submodule.commands, message)
else:
Expand Down