001 /** 002 * 003 */ 004 package edu.nrao.sss.astronomy; 005 006 import java.util.Arrays; 007 008 import edu.nrao.sss.util.EnumerationUtility; 009 import edu.nrao.sss.util.StringUtil; 010 011 /** 012 * A frame of rest against which a velocity is measured. 013 * <p> 014 * This list was based on the list found at 015 * <a href="http://www.gb.nrao.edu/~fghigo/gbtdoc/doppler.html"> 016 * http://www.gb.nrao.edu/~fghigo/gbtdoc/doppler.html</a>. 017 * <p> 018 * <b>CVS Info:</b> 019 * <table style="margin-left:2em"> 020 * <tr><td>$Revision: 161 $</td></tr> 021 * <tr><td>$Date: 2006-12-15 11:48:34 -0700 (Fri, 15 Dec 2006) $</td></tr> 022 * <tr><td>$Author: btruitt $</td></tr> 023 * </table></p> 024 * 025 * @author David M. Harland 026 * @since 2006-03-31 027 */ 028 public enum VelocityFrame 029 { 030 /** 031 * Rest frame based on the observer's position. 032 */ 033 TOPOCENTRIC, 034 035 /** 036 * Rest frame based on the earth's center of mass. 037 */ 038 GEOCENTRIC, 039 040 /** 041 * Rest frame based on our solar system's center of mass. 042 */ 043 BARYCENTRIC, 044 045 /** 046 * Rest frame based on our sun's center of mass. 047 */ 048 HELIOCENTRIC, 049 050 /** 051 * Conventional Local Standard of Rest. 052 * <p> 053 * From the source in the class comments, this is: 054 * <blockquote> 055 * based on average velocity of stars in the Solar neighborhood. 056 * </blockquote> 057 */ 058 LSR_KINEMATIC("LSR-K"), 059 060 /** 061 * Dynamic Local Standard of Rest. 062 * <p> 063 * From the source in the class comments, this is: 064 * <blockquote> 065 * [The] solar peculiar velocity with respect to a frame in circular 066 * motions about the galactic center. 067 * </blockquote> 068 */ 069 LSR_DYNAMIC("LSR-D"), 070 071 /** 072 * Rest frame based on our galaxy's center of mass. 073 */ 074 GALACTOCENTRIC, 075 076 /** 077 * Rest frame based on the our local group of galaxies' center of mass. 078 */ 079 LOCAL_GROUP, 080 081 /** 082 * Rest frame based on <i>COBE measurements of dipole anisotropy</i>. 083 * (The description above was taken from the source listed in 084 * the class comments.) 085 */ 086 COSMIC_MICROWAVE_BACKGROUND("CMB"), 087 088 /** 089 * An unknown rest frame. 090 * <p> 091 * This element is used to implement the 092 * <i>Null Object Pattern</i>. In situations where a method might 093 * be tempted to return <i>null</i>, this element is returned instead.</p> 094 */ 095 UNKNOWN; 096 097 //private Set<String> aliases = new HashSet<String>(); 098 private final String[] aliases; 099 100 private VelocityFrame(String... aliases) 101 { 102 this.aliases = aliases; 103 Arrays.sort(this.aliases); 104 } 105 106 /** 107 * Returns a default velocity frame. 108 * @return a default velocity frame. 109 */ 110 public static VelocityFrame getDefault() 111 { 112 return UNKNOWN; 113 } 114 115 /** 116 * Returns a text representation of this enumeration constant. 117 * @return a text representation of this enumeration constant. 118 */ 119 public String toString() 120 { 121 return EnumerationUtility.getSharedInstance().enumToString(this); 122 } 123 124 /** 125 * Returns the velocity frame represented by {@code text}. 126 * <p> 127 * For details about the transformation, see 128 * {@link EnumerationUtility#enumFromString(Class, String)}.</p> 129 * 130 * @param text a text representation of a velocity frame. 131 * 132 * @return the velocity frame system represented by {@code text}. 133 */ 134 public static VelocityFrame fromString(String text) 135 { 136 //Try standard approach first 137 VelocityFrame result = EnumerationUtility.getSharedInstance() 138 .enumFromString(VelocityFrame.class, 139 text); 140 //If no match found, search aliases 141 if (result == null) 142 { 143 text = StringUtil.getInstance().normalizeString(text); 144 for (VelocityFrame elem : VelocityFrame.values()) 145 { 146 //See if the parameter name is in the list of the epoch's acceptable names. 147 //NOTE: This relies on the fact that the aliases have been sorted. 148 if (Arrays.binarySearch(elem.aliases, text.toUpperCase()) >= 0) 149 { 150 result = elem; 151 break; 152 } 153 } 154 } 155 156 return result; 157 } 158 }