00001
00002
00003
00004
00005
00006 #include <string.h>
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <math.h>
00010 #include <unistd.h>
00011 #include <time.h>
00012
00013 #include "nrutil.h"
00014
00015 #include <jsoc_main.h>
00016
00017 #define CODE_NAME "limbfit_ann"
00018 #define CODE_VERSION "V1r0"
00019 #define CODE_DATE "Mon Sep 15 15:14:19 PDT 2014"
00020 #define LOGMSG1 "LIMBFITS_ANN"
00021 #define JSD_NAME "scholl_limbfit_ann.jsd"
00022
00023
00024
00025
00026
00027
00028 #define NUMRECPERTRANS 960 // must be equal to Unitsize in the JSD
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #define ERR_EXIT 1
00041 #define ERR_USAGE -2
00042 #define ERR_MALLOC_FAILED -11
00043 #define ERR_SPECIAL -100
00044 #define ERR_DRMS_WRITE -200
00045 #define ERR_DRMS_READ -201
00046 #define ERR_DRMS_ARRAY_CREATE -202
00047 #define ERR_DRMS_SEGMENT_WRITE -203
00048 #define ERR_DRMS_SEGMENT_LOOKUPNUM -204
00049 #define WAR_DRMS_NORECORD 201
00050 #define WAR_DRMS_FREE_ARRAY 202
00051 #define DEBUG_MSG 999
00052 #define VOID 0
00053
00054
00055 #define ERR_DRMS_WRITE_KW -300
00056 #define ERR_DRMS_READ_MISSING_DATA -301
00057 #define ERR_DRMS_READ_MISSING_KW -302
00058 #define ERR_DRMS_READ_MISSING_XYR_LA -303
00059 #define ERR_NR_STACK_TOO_SMALL -352
00060
00061
00062 #define ERR_LIMBANN_FAILED -501
00063 #define ERR_DISK_OUTSIDE_IMAGE -511
00064 #define ERR_SIZE_ANN_TOO_BIG -512
00065
00066
00067 #define PROCSTAT_OK "OK"
00068 #define PROCSTAT_NOK "NOK"
00069 #define PROCSTAT_NO_LA_FAILED "LF_FAILED"
00070 #define PROCSTAT_NO_LA_MISSVALS "NO_LA_MISSVALS"
00071 #define PROCSTAT_NO_LA_DARKIMG "NO_LA_DARKIMG"
00072 #define PROCSTAT_NO_LA_OPENLOOP "NO_LA_OPENLOOP"
00073 #define PROCSTAT_NO_LA_DB_READ_PB "NO_LA_DB_READ_PB"
00074 #define PROCSTAT_NO_LA_XYR_LF_MISSING "NO_LA_XYR_LF_MISSING"
00075 #define PROCSTAT_NO_LA_DB_WRITE_PB "NO_LA_DB_WRITE_PB"
00076
00077
00078 #define EQNANVAL -2147483648 // NAN equivalent
00079 #define IMG_SIZE 16777216 // = 4096*4096
00080 #define CENTX 2048.0
00081 #define CENTY 2048.0
00082 #define R_MAX 1985.0
00083 #define R_MIN 1825.0
00084 #define NAXIS_ROW 4096
00085 #define NAXIS_COL 4096
00086
00087
00088 typedef struct {
00089 int *mask;
00090 int *pf_mask;
00091 int *pl_mask;
00092 unsigned int fsn;
00093 double ix;
00094 double iy;
00095 } LIMBFIT_INPUT;
00096
00097 typedef struct {
00098
00099
00100 float cmean;
00101 int quality;
00102 float cenx;
00103 float ceny;
00104 float r_min;
00105 float r_max;
00106
00107
00108 char* dsin;
00109 char* comment;
00110 char* code_date;
00111 char* code_version;
00112 char* code_name;
00113 char* bld_vers;
00114 char* series_name;
00115
00116
00117 FILE *opf;
00118 char* tmp_dir;
00119 char* dsout;
00120 int debug;
00121
00122 } LIMBFIT_OUTPUT;
00123
00124
00125 void close_on_error(DRMS_Record_t *record_in,DRMS_Record_t *record_out, DRMS_Array_t *data_array);
00126 int do_one_limbfit(DRMS_Record_t *record_in,DRMS_Record_t *record_out,
00127 LIMBFIT_INPUT *input, LIMBFIT_OUTPUT *results, int *status);
00128 void get_sdate(char *sdate);
00129 void lf_logmsg(char * type1, char * type2, int return_code, int status, char *message, char *code_name, FILE *opf);
00130 int process_n_records_fsn(char * open_dsname, LIMBFIT_INPUT *lfv, LIMBFIT_OUTPUT *lfr, int *status);
00131 int process_all_records_smpl(char * open_dsname, LIMBFIT_INPUT *lfv, LIMBFIT_OUTPUT *lfr, int *status);
00132 int write_mini_output(char * errcode, DRMS_Record_t *record_in,DRMS_Record_t *record_out,int tbf, LIMBFIT_OUTPUT *lfr);
00133 int write_lf_keywords(char * errcode, DRMS_Record_t *record_out, LIMBFIT_OUTPUT *results, int pass);
00134