Commit 27fdb9844d83d88659372142278f12f1bfe18592

Authored by Alain Klotz
1 parent 7ac47a69
Exists in master

Debug WCS.

src/guitastro/astrotables.py
... ... @@ -149,7 +149,7 @@ class AstroTable(AstroTableException, GuitastroTools):
149 149 * **rencol**: Rename a given column named.
150 150  
151 151 To manage rows:
152   - * **gelrow**: Returns a row of a given line index.
  152 + * **getrow**: Returns a row of a given line index.
153 153 * **setrow**: Insert a new row at before a given line index.
154 154 * **delrow**: Delete a row of a given line index.
155 155 * **delrows**: Delete rows.
... ... @@ -159,6 +159,7 @@ class AstroTable(AstroTableException, GuitastroTools):
159 159  
160 160 * **getcell**: Returns the value of column name at a given row index.
161 161 * **setcell**: Modify the value of column name at a given row index.
  162 + * **getcells**: Returns a list of a list of all the table cell contents.
162 163  
163 164 To manage metadata:
164 165  
... ... @@ -771,6 +772,26 @@ class AstroTable(AstroTableException, GuitastroTools):
771 772 msg = f"Input row index {index} must be from 0 to {nrow-1}"
772 773 raise AstroTableException(AstroTableException.BAD_IDXLIG, msg)
773 774  
  775 + def getcells(self):
  776 + """Returns a list of a list of all the table cell contents.
  777 +
  778 + Example:
  779 +
  780 + ::
  781 +
  782 + at = AstroTable()
  783 + at.table(None)
  784 + at.getcells()
  785 +
  786 + """
  787 + nrow, ncol = self.shape()
  788 + cols = []
  789 + colnames = self.getcols()
  790 + for colname in colnames:
  791 + col = self.getcol(colname)
  792 + cols.append(col)
  793 + return cols
  794 +
774 795 # =============================================
775 796 # Manage table rows
776 797 # =============================================
... ... @@ -1856,6 +1877,9 @@ class AstroTable(AstroTableException, GuitastroTools):
1856 1877 if output_type=="IDRADECVAR" or output_type=="VAR":
1857 1878 columns = ['Name', 'RAJ2000', 'DEJ2000', 'max', 'min', 'Type', 'Epoch', 'Period'] # '_tab1_15'
1858 1879 colnames = ['id', 'ra', 'dec', 'magVmax', 'magVmin', 'VarType', 'EpochMax', 'Period']
  1880 + elif cat_name == "ASTROTABLE":
  1881 + # use at.read() before to have a table in memory
  1882 + return
1859 1883 else:
1860 1884 msg = f"Catalog name {cat_name} must be amongst: "
1861 1885 msg += "GAIA, PS1, SDSS, UCAC, USNOA2, USNOB1, TYCHO, NOMAD, HIPARCOS, 2MASS, GCVS, VSX"
... ...
src/guitastro/dates.py
... ... @@ -272,6 +272,8 @@ class Date(GuitastroTools):
272 272 str_date = str(date).upper()
273 273 str_split = str_date.split(" ")
274 274 str_nsplit = len(str_split)
  275 + if str_date == "":
  276 + str_date = "NOW"
275 277 if str_date == "NOW":
276 278 # style NOW
277 279 utc_datetime = datetime.datetime.utcnow()
... ...
src/guitastro/ima.py
... ... @@ -125,8 +125,9 @@ class ImaException(GuitastroException):
125 125 KEY_NOT_FOUND = 10
126 126 NOT_ENOUGH_ARGS = 11
127 127 FILE_DOES_NOT_EXIST = 12
  128 + ARG_MUST_BE_ASTROTABLE_TYPE= 13
128 129  
129   - errors = [""]*13
  130 + errors = [""]*14
130 131 errors[BUFFER_EMPTY] = "Ima is empty"
131 132 errors[SHAPES_NOT_SAME] = "Shapes of images are not the same"
132 133 errors[WCS_KEYS_NOT_FOUND] = "WCS keys not found or not valid in the FITS header"
... ... @@ -140,7 +141,7 @@ class ImaException(GuitastroException):
140 141 errors[KEY_NOT_FOUND] = "key not found in the FITS header"
141 142 errors[NOT_ENOUGH_ARGS] = "Not enough arguments"
142 143 errors[FILE_DOES_NOT_EXIST] = "The file does not exist"
143   -
  144 + errors[ARG_MUST_BE_ASTROTABLE_TYPE] = "The argument must be of Astrotable type"
144 145  
145 146 class Ima(ImaException, FileNames):
146 147 """ Class to analyze or process an image for astronomy
... ... @@ -2812,13 +2813,33 @@ class Ima(ImaException, FileNames):
2812 2813 self._verify_buffer()
2813 2814 self._array = np.multiply(self._array, cste)
2814 2815  
  2816 + def ngain(self, meanvalue:float):
  2817 + """Normalize the current mean value of the pixels to meanvalue.
  2818 +
  2819 + Args:
  2820 + meanvalue: Normalization value.
  2821 +
  2822 + Example, normalize to 200 :
  2823 +
  2824 + ::
  2825 +
  2826 + ima = Ima()
  2827 + ima.load("m57")
  2828 + ima.ngain(200)
  2829 +
  2830 + """
  2831 + self._verify_buffer()
  2832 + mean = np.mean(self._array)
  2833 + mult = meanvalue / mean
  2834 + self._array = np.multiply(self._array, mult)
  2835 +
2815 2836 def offset(self, cste:float):
2816 2837 """Add a constant value to all the pixels of the image.
2817 2838  
2818 2839 Args:
2819 2840 cste: Constant value to add to all pixels.
2820 2841  
2821   - Example, add a valuie of 1023 to all the pixels:
  2842 + Example, add a value of 1023 to all the pixels:
2822 2843  
2823 2844 ::
2824 2845  
... ... @@ -3082,8 +3103,23 @@ class Ima(ImaException, FileNames):
3082 3103 kwarg_catas[key] = val
3083 3104 fov1 = self.etc._etc["comp1"]["FoV1"][0]
3084 3105 fov2 = self.etc._etc["comp1"]["FoV2"][0]
3085   - print(f"kwarg_catas={kwarg_catas}")
3086   - at.catalog(ra, dec, fov1, fov2, *args, **kwarg_catas)
  3106 + #print(f"kwarg_catas={kwarg_catas}")
  3107 + if args[0].upper() == "ASTROTABLE":
  3108 + att = args[1]
  3109 + if str(type(att)) == "<class 'guitastro.astrotables.AstroTable'>":
  3110 + cols = att.getcells()
  3111 + names = att.getcols()
  3112 + kwds = att.getkwds()
  3113 + meta = {}
  3114 + for kwd in kwds:
  3115 + val = att.getkwd(kwd)
  3116 + meta[kwd] = val
  3117 + at.table(cols, names=names, meta=meta)
  3118 + else:
  3119 + texte = f"Args[1] {str(type(att))}"
  3120 + raise ImaException(ImaException.ARG_MUST_BE_ASTROTABLE_TYPE,texte)
  3121 + else:
  3122 + at.catalog(ra, dec, fov1, fov2, *args, **kwarg_catas)
3087 3123 at.radec2xy()
3088 3124 cols = at.getcols()
3089 3125 for col in cols:
... ...