net.grelf.astro
Class MagnitudeGraph

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by net.grelf.astro.MagnitudeGraph
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable

public class MagnitudeGraph
extends javax.swing.JComponent
implements java.awt.print.Printable

A GUI component for displaying a graph of blob brightnesses against known stellar magnitudes, doing a least-squares fit and then estimating unknown magnitudes from brightnesses.

The brightness measurements may be inaccurate because of noise in the image. The outer ring around each blob is measured to determine the background level in the vicinity. That process includes calculating the standard deviation (ϭ0) of the mean background level which, because the ring is small, is predominantly due to the noise. It is a reasonable assumption that if the star were not present in the central measurement disc the same mean background level would continue across it, with the same standard deviation. Therefore the measurement of each star's brightness, B, is subject to the same errors at each pixel as in the outer ring. In calculating that brightness we add up the brightnesses of every pixel after subtracting from them the mean background level (that is done separately in each channel if it is a coloured image). So at each pixel we are subtracting pairs of values that are subject to the same possible error. The result therefore has a larger error, perhaps by as much as a factor of 2. My guess is that a fair estimate would be to multiply the background standard error (S0, standard deviation over root number of samples) by root 2 at each point to get the standard error of the star brightness levels.

If n0 is the number of pixels measured in the background ring, the standard error of the mean background is

S0 = ϭ0 / √n0 by definition.

Then using similar symbols but with subscript B for each star brightness measurement:

SB = 1.414 S0 at each pixel, so for the whole brightness integration

SB = 1.414 √nB S0

(The standard error means we can quote values of brightness as being B ± SB.)

The least-squares straight line fitting uses log10 B. We can estimate the standard error for that as

SLB = (log10 (B + SB) - log10 (B - SB)) / 2

From that we get standard deviation values to feed into the fitting for each reference star:

ϭLB = √nB SLB

The fitting algorithm finds gradient g and intercept c of the linear relationship between brightness B and magnitude M:

B = gM + c

It also returns values for the standard deviations of g and c, ϭg and ϭc respectively.

The fitting is done for nR reference stars so we can find the standard errors of g and c:

Sg = ϭg / √nR and

Sc = ϭc / √nR

The unknown magnitude is then calculated as the inverse of the linear relationship:

M = (B - c) / g

We want to be able to quote M ± SM

The standard error SM can be estimated by using the inverse linear relationship on the 4 values g ± Sg and c ± Sc and taking half the difference between the extreme results as the value of SM.

The sample sizes for both the background ring and the star brightness disc will always be larger than 10 (typically there are 100 or more pixels in each) so we can safely multiply the standard error by 2 to get 95% confidence intervals and that will be done on the magnitude estimation graph. There is quite a good description at http://jcb.rupress.org/cgi/content/full/177/1/7 of the difference between standard deviation, standard error and confidence intervals and why the latter are often preferable in reporting experimental results.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MagnitudeGraph(ImFrame parent, java.lang.String title, BlobMeasList meases, MagnitudeBands bands, java.lang.String filePath, TimeInterval timeSpan)
          Any BlobMeas objects that have a star with an id but no magnitude will have magnitudes estimated by least squares fitting.
 
Method Summary
protected  void draw(java.awt.Graphics2D g2, int xOffset, int yOffset)
           
static javax.print.attribute.HashPrintRequestAttributeSet getAtts()
           
 boolean isAccurate()
          Find out whether the graph was created using accurate brightness measurements (rather than the less accurate brightnesses as initially detected).
 void paintComponent(java.awt.Graphics g)
           
 int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageNo)
           
 void saveDataAsXML()
          Save the measured results as an XML file, designed to be easy to incorporate into a larger XML file of several such measurements.
 void showGraph()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MagnitudeGraph

public MagnitudeGraph(ImFrame parent,
                      java.lang.String title,
                      BlobMeasList meases,
                      MagnitudeBands bands,
                      java.lang.String filePath,
                      TimeInterval timeSpan)
               throws InadequateDataException
Any BlobMeas objects that have a star with an id but no magnitude will have magnitudes estimated by least squares fitting. The DateTime parameters may be null but if they are not they will be shown on the graph along with Julian date equivalents. Parameters filePath and timeSpan refer to the image being measured, which is the parent of the blob menu image.
NB: Only works for images having 1 (mono) or 3 (assumed to be RGB) channels.

Throws:
InadequateDataException
Method Detail

isAccurate

public boolean isAccurate()
Find out whether the graph was created using accurate brightness measurements (rather than the less accurate brightnesses as initially detected).


draw

protected void draw(java.awt.Graphics2D g2,
                    int xOffset,
                    int yOffset)

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pageNo)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
Throws:
java.awt.print.PrinterException

getAtts

public static javax.print.attribute.HashPrintRequestAttributeSet getAtts()

showGraph

public void showGraph()

saveDataAsXML

public void saveDataAsXML()
Save the measured results as an XML file, designed to be easy to incorporate into a larger XML file of several such measurements.