ops

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaterializeAll

func MaterializeAll(ins []Promise, maxThreads int, forget bool) (outs []*fits.Image, err error)

Materializes all promises with given concurrency limit

func RemoveNils

func RemoveNils(lights []*fits.Image) []*fits.Image

Remove nils from an array of fits.Images, editing the underlying array in place

func SetOperatorFactory

func SetOperatorFactory(f OperatorFactory)

Registers a given type string for a given type of UnaryOperator, identified via an exemplar generator

Types

type Context

type Context struct {
	Log             io.Writer
	LSEstimatorMode stats.LSEstimatorMode
	MemoryMB        int // memory.TotalMemory()/1024/1024
	StackMemoryMB   int // MemoryMB*7/10
	MaxThreads      int `json:"maxThreads"`
	DarkFrame       *fits.Image
	FlatFrame       *fits.Image
	RefFrame        *fits.Image
	RefFrameError   error
	LumFrame        *fits.Image
}

An execution context for operators

func NewContext

func NewContext(log io.Writer, lsEstimatorMode stats.LSEstimatorMode) *Context

type OpBase

type OpBase struct {
	Type string `json:"type"`
}

Base type for operators, including type information for JSON serializing/deserializing

func (*OpBase) GetType

func (op *OpBase) GetType() string

type OpLoad

type OpLoad struct {
	OpBase
	ID       int    `json:"id"`
	FileName string `json:"fileName"`
}

Load a single FITS image from a single filename. Takes zero inputs, produces one output

func NewOpLoad

func NewOpLoad(id int, fileName string) *OpLoad

func NewOpLoadDefault

func NewOpLoadDefault() *OpLoad

func (*OpLoad) Apply

func (op *OpLoad) Apply(f *fits.Image, c *Context) (result *fits.Image, err error)

func (*OpLoad) MakePromises

func (op *OpLoad) MakePromises(ins []Promise, c *Context) (outs []Promise, err error)

Load image from a file. Ignores any f argument provided

func (*OpLoad) UnmarshalJSON

func (op *OpLoad) UnmarshalJSON(data []byte) error

Unmarshal the type from JSON with default values for missing entries

type OpLoadMany

type OpLoadMany struct {
	OpBase
	FilePatterns []string `json:"filePatterns"`
}

Load many FITS images from a slice of filename patterns with wildcards. Takes zero inputs, produces n outputs

func NewOpLoadMany

func NewOpLoadMany(filePatterns []string) *OpLoadMany

func NewOpLoadManyDefault

func NewOpLoadManyDefault() *OpLoadMany

func (*OpLoadMany) MakePromises

func (op *OpLoadMany) MakePromises(ins []Promise, c *Context) (outs []Promise, err error)

Turn filename wildcards into list of file load operators

func (*OpLoadMany) UnmarshalJSON

func (op *OpLoadMany) UnmarshalJSON(data []byte) error

Unmarshal the type from JSON with default values for missing entries

type OpSave

type OpSave struct {
	OpUnaryBase
	FilePattern string `json:"filePattern"`
}

Saves given promise under a given filename, with pattern expansion for %d based on the image id. Takes one input, produces one output (the materialized but unchanged input)

func NewOpSave

func NewOpSave(filenamePattern string) *OpSave

func NewOpSaveDefault

func NewOpSaveDefault() *OpSave

func (*OpSave) Apply

func (op *OpSave) Apply(f *fits.Image, c *Context) (result *fits.Image, err error)

func (*OpSave) UnmarshalJSON

func (op *OpSave) UnmarshalJSON(data []byte) error

Unmarshal the type from JSON with default values for missing entries

type OpSequence

type OpSequence struct {
	OpBase
	Steps    []Operator        `json:"-"`     // the actual steps
	StepsRaw []json.RawMessage `json:"steps"` // helper for unmarshaling
}

Applies a sequence of operators to a promise. Number of inputs, outputs as per the chained steps

func NewOpSequence

func NewOpSequence(steps ...Operator) *OpSequence

func NewOpSequenceDefault

func NewOpSequenceDefault() *OpSequence

func (*OpSequence) Append

func (op *OpSequence) Append(steps ...Operator)

Appends one or more operators to the existing sequence

func (*OpSequence) MakePromises

func (op *OpSequence) MakePromises(ins []Promise, c *Context) (outs []Promise, err error)

func (*OpSequence) MarshalJSON

func (op *OpSequence) MarshalJSON() (bs []byte, err error)

Marshals a sequence with polymorphic operators to JSON. Uses the actual op.Steps with label "steps", and ignores op.StepsRaw

func (*OpSequence) UnmarshalJSON

func (op *OpSequence) UnmarshalJSON(b []byte) error

Unmarshals a sequence of polymorphic operators from JSON. Uses temporary op.StepsRaw inspired by https://alexkappa.medium.com/json-polymorphism-in-go-4cade1e58ed1

type OpUnaryBase

type OpUnaryBase struct {
	OpBase
	Apply func(f *fits.Image, c *Context) (fOut *fits.Image, err error) `json:"-"`
}

Abstract base type for unary operators. Uses golang workaround for abstract classes from https://golangbyexample.com/go-abstract-class/

func (*OpUnaryBase) MakePromise

func (op *OpUnaryBase) MakePromise(in Promise, c *Context) (out Promise)

func (*OpUnaryBase) MakePromises

func (op *OpUnaryBase) MakePromises(ins []Promise, c *Context) (outs []Promise, err error)

type Operator

type Operator interface {
	GetType() string
	MakePromises(ins []Promise, c *Context) (outs []Promise, err error)
}

An general image processing operator: takes n promises as inputs, and produces m promises as output or an error

type OperatorFactory

type OperatorFactory func() Operator

Factory method for subclasses of unary operators. For JSON serializing/deserializing

func GetOperatorFactory

func GetOperatorFactory(t string) OperatorFactory

Returns the operator factory for a given type string

type OperatorUnary

type OperatorUnary interface {
	Operator
	Apply(f *fits.Image, c *Context) (fOut *fits.Image, err error)
}

A unary image processing operator: given n promises as inputs, applies itself to each of them individually and returns n output promises or an error

type Promise

type Promise func() (f *fits.Image, err error)

A promise for a FITS image. Returns a materialized image, or an error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL