Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

lib/misc.c

Go to the documentation of this file.
00001 /* === Doxygen Comment ======================================= */
00015 /* =========================================================== */
00016 
00017 #include <IFU_io.h>
00018 #include <IFU_math.h>
00019 #include <snifs.h>
00020 #include <stdlib.h>                          /* atexit() */
00021 
00022 /* === Doxygen Comment ======================================= */
00026 /* =========================================================== */
00027 
00028 void banner_snifs(void)
00029 {
00030   /* Goodbye msg */
00031   if (VERBOSE && !TK) {
00032     print_msg("+------- SNifs Ultimate Reduction Package -------+");
00033     print_msg("| Webpage: http://snfactory.in2p3.fr/soft/snifs/ |");
00034     print_msg("| Contact: y.copin@ipnl.in2p3.fr                 |");
00035     print_msg("+------------------------------------------------+");
00036   }
00037 }
00038 
00039 /* === Doxygen Comment ======================================= */
00050 /* =========================================================== */
00051 
00052 void init_snifs(char *cvsname, char *cvsversion) 
00053 {
00054   char *tmpname, *tmpvers, *name, *version, *end, ifuvers[20];
00055 
00056   /* Parse the CVS-name "$Name:  $" to extract the real name */
00057   tmpname = strdup(cvsname);
00058   name = strchr(tmpname,' ');                /* Look for 1st blank */
00059   if (name == NULL) name = tmpname;
00060   else              name+= 1;
00061   end = strrchr(tmpname,' ');                /* Look for last blank */
00062   if (end != NULL) *end = '\0';              /* Terminate name there */
00063 
00064   /* Parse the CVS-version "$Revision: 1.8 $" to extract the version number */
00065   tmpvers = strdup(cvsversion);
00066   version = strchr(tmpvers,' ');             /* Look for 1st blank */
00067   if (version == NULL) version = tmpvers;
00068   else                 version+= 1;
00069   end = strrchr(tmpvers,' ');                /* Look for last blank */
00070   if (end != NULL) *end = '\0';              /* Terminate name there */
00071 
00072   /* Set version. Beware the length of ifuvers wrt soft_version IFU
00073      global variable defined in iolib.c */
00074   sprintf(ifuvers,"%s/%s", strlen(name)? name:"developer", version);
00075   set_version(ifuvers);
00076 
00077   free(tmpname); free(tmpvers);              /* Allocated by strdup */
00078 
00079   atexit(banner_snifs);                      /* Display banner at very end of pgm */
00080 }
00081 
00082 /* === Doxygen Comment ======================================= */
00090 /* =========================================================== */
00091 
00092 float read_exptime(void *anyfile) 
00093 {
00094   float exptime;
00095   
00096   disable_user_warnings();
00097   if (RD_desc(anyfile, EFFTIME, FLOAT, 1, &exptime) < 0) {
00098     exptime = -1;
00099     print_warning("%s descriptor absent from %s", EFFTIME,((Anyfile *)anyfile)->name);
00100     print_warning("+----------------------------------------------------------+");
00101     print_warning("| Beware that the spectro. exposure time as described by   |");
00102     print_warning("| the EXPTIME keyword is 10s too long. Set the new EFFTIME |");
00103     print_warning("| keyword to correct value (see P channel for real exptime)|");
00104     print_warning("+----------------------------------------------------------+");
00105   } 
00106   else if (DEBUG) {
00107     print_msg("%s in frame %s: %.1fs",
00108               EFFTIME,((Anyfile *)anyfile)->name,exptime);
00109   }
00110   restore_user_warnings();
00111 
00112   return(exptime);
00113 }
00114 
00115 /* === Doxygen Comment ======================================= */
00119 /* =========================================================== */
00120 
00121 float read_airmass(void *anyfile) 
00122 {
00123   float airmass;
00124   
00125   disable_user_warnings();
00126   if (RD_desc(anyfile, AIRMASS, FLOAT, 1, &airmass) < 0) {
00127     airmass = 0;
00128     print_warning("%s descriptor absent from %s", AIRMASS,((Anyfile *)anyfile)->name);
00129   } 
00130   else if (DEBUG) {
00131     print_msg("%s of frame %s: z = %.3g",
00132               AIRMASS,((Anyfile *)anyfile)->name,airmass);
00133   }
00134   restore_user_warnings();
00135 
00136   return(airmass);
00137 }
00138 
00139 /* === Doxygen Comment ======================================= */
00149 /* =========================================================== */
00150 
00151 float check_airmass(char *arcname, float cal_airmass, 
00152                     char *objname, float obj_airmass) 
00153 {
00154   float diff;
00155 
00156   if (cal_airmass < 1 || obj_airmass < 1) {
00157     print_warning("Airmass of %s or %s is unset, cannot compute zenithal distance",
00158                   arcname,objname);
00159     return(-1);
00160   }
00161   
00162   diff = ABS(acos(1./cal_airmass) - acos(1./obj_airmass))*180/M_PI;
00163   if (DEBUG) 
00164     print_msg("Zenithal distance calibration %s/object %s: %.1f deg", 
00165               arcname,objname,diff);
00166   
00167   if (diff > 15.) 
00168     print_warning("Zenithal distance calibration %s/object %s > 1h (%.1f deg)",
00169                   arcname,objname,diff);
00170   
00171   return(diff);
00172 }
00173 

Generated on Wed Oct 26 23:59:39 2005 for Snifs by doxygen 1.3.5