DAS  3.1.6 - 18/09/2017
Macros | Functions | Variables
Utils.c File Reference

Functions for spectra correction + Others. More...

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dcl.h"
#include "dil.h"
#include "bil.h"
#include "DOAS.h"
#include "nrutil.h"
#include "Marq.h"
+ Include dependency graph for Utils.c:

Go to the source code of this file.

Macros

#define FREERETURN   {free_vector(d,1,n);free_vector(c,1,n);return;}
 
#define PI   3.1415926
 
#define TINY   1.0e-25
 

Functions

double CalcFluxIndex (unsigned short mis[], int dx, int dy, float te)
 calculates the Flux Index of a measurement More...
 
void D_CloseVR (MOBJECT p, void *od, void *ad)
 Callback closing the status bar. More...
 
void D_Print_BIL_H_ASCII (int mod, FILE *fff)
 
void D_PrintBILSPH (FILE *fff)
 Print Header. More...
 
void D_PrintBILSPH_BIN (int fd)
 Print on file the binary header of the measured spectrum. More...
 
void D_PrintSpectrum (FILE *fff)
 Print Spectrum. More...
 
void D_VRange (char *str, int val, int r, int g, int b)
 Create and display the status bar. More...
 
void D_VRangeSim (int id, char *str, int val, int r, int g, int b, int x, int y)
 init progress bar during simultaneous positioning More...
 
int DB_CalcFluxI (char *nomefile)
 
void __stdcall DD_VRange (const char *str, int val, int Port)
 
int DT_ColFormat (void)
 Callback for Column format. More...
 
int DT_CorrFileEvora (void)
 Used to correct some data files. More...
 
int DT_CorrHeader ()
 Used to correct the header in some data files. More...
 
int DT_FluxIndex (void)
 Callback for Flux Index Calculation. More...
 
int DT_LinkSpectra (void)
 For the linked spectra (..on going!!!) More...
 
int Model_read (char *buff)
 
void polint (float xa[], float ya[], int n, float x, float *y, float *dy)
 
int polintlambda (void)
 
void ShiftImg (int hp, int vp)
 Used to correct some data files. More...
 

Variables

bil BIL
 
int D_VOpen = 0
 
int D_VRip = -1
 
int DD_VOpen [16]
 
int DD_VRip [16]
 
palette DPAL
 

Detailed Description

Functions for spectra correction + Others.

Author
Daniele Bortoli

Definition in file Utils.c.

Macro Definition Documentation

§ FREERETURN

#define FREERETURN   {free_vector(d,1,n);free_vector(c,1,n);return;}

Definition at line 32 of file Utils.c.

§ PI

#define PI   3.1415926

Definition at line 33 of file Utils.c.

§ TINY

#define TINY   1.0e-25

Definition at line 31 of file Utils.c.

Function Documentation

§ CalcFluxIndex()

double CalcFluxIndex ( unsigned short  mis[],
int  dx,
int  dy,
float  te 
)

calculates the Flux Index of a measurement

Parameters
mis[]data array
dxhorizontal pixels
dyvertical pixels
teexposure time
Returns
: Flux Index
Parameters
*nomefilesource file name

Definition at line 306 of file Utils.c.

Referenced by DB_CalcFluxI().

307 {
308 
309  int x;
310  long sumdata = 0;
311  double average = 0;
312  double fluxi = 0;
313 
314 
315  for(x = 200; x < dx - 200 ; x++)
316  {
317  sumdata += mis[ dy * dx + x];
318  }
319 
320  average = sumdata / (double) (dx - 400);
321 
322  fluxi = average / (double)(te * 1000000);
323 
324  return fluxi;
325 
326 }
+ Here is the caller graph for this function:

§ D_CloseVR()

void D_CloseVR ( MOBJECT  p,
void *  od,
void *  ad 
)

Callback closing the status bar.

Definition at line 140 of file Utils.c.

References MShellDestroy(), and MShellUnrealize().

Referenced by D_VRange(), D_VRangeSim(), and DD_VRange().

141 {
143  MShellDestroy(p);
144 
145 
146 }
void MShellUnrealize(MOBJECT obj)
void MShellDestroy(MOBJECT obj)
static double p
Definition: SOLPOS.C:131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_Print_BIL_H_ASCII()

void D_Print_BIL_H_ASCII ( int  mod,
FILE *  fff 
)

Definition at line 621 of file Utils.c.

References spectrumheader::altitude, spectrumheader::ccdex, spectrumheader::ccdey, spectrumheader::ccdmax, spectrumheader::ccdmin, spectrumheader::ccdnr, spectrumheader::ccdsx, spectrumheader::ccdsy, spectrumheader::ccdtemp, spectrumheader::ccdtexp, spectrumheader::ccdvb, spectrumheader::ccdwx, spectrumheader::ccdwy, spectrumheader::comment, ddate::da_day, ddate::da_mon, ddate::da_year, spectrumheader::DATE, spectrumheader::dummy1, spectrumheader::dummy2, spectrumheader::dummy3, spectrumheader::dummy4, spectrumheader::filpos, spectrumheader::imgtype, spectrumheader::latitude, spectrumheader::location, spectrumheader::longitude, spectrumheader::mirpos, bil::SPH, spectrumheader::sza, dtime::ti_hour, dtime::ti_min, dtime::ti_sec, spectrumheader::TIME, and spectrumheader::wavelen.

Referenced by SaveDataOffLine(), and SaveIo().

622 {
623 
624  fprintf(fff, "LOC: %s ", BIL.SPH.location); //Name of the station
625  fprintf(fff, "LAT: %.2lf ", BIL.SPH.latitude);//Station latitude
626  fprintf(fff, "LON: %.2lf ", BIL.SPH.longitude);//Station latitude
627  fprintf(fff, "ALT[m/asl]: %u ", BIL.SPH.altitude);//Station altitude
628  fprintf(fff, "SZA: %.2lf\n", BIL.SPH.sza);//SZA
629 
630  fprintf(fff, "%d/%02d/%02d ", BIL.SPH.DATE.da_year, BIL.SPH.DATE.da_mon, BIL.SPH.DATE.da_day);
631  fprintf(fff, "%02d:%02d:%02d LT ",BIL.SPH.TIME.ti_hour, BIL.SPH.TIME.ti_min,BIL.SPH.TIME.ti_sec);
632  fprintf(fff, "%s ", BIL.SPH.mirpos);
633  fprintf(fff, "%d ", BIL.SPH.wavelen);
634  fprintf(fff, "%s ", BIL.SPH.filpos);
635  fprintf(fff, "%.2lf ", BIL.SPH.ccdtemp);
636  fprintf(fff, "%.2lf ", BIL.SPH.ccdtexp);
637  fprintf(fff, "%5u ", BIL.SPH.ccdmax);
638  fprintf(fff, "%5u\n", BIL.SPH.ccdmin);
639 
640 
641  // Image format
642  fprintf(fff, "%d ", BIL.SPH.imgtype);
643  fprintf(fff, "%d ", BIL.SPH.ccdwx);
644  fprintf(fff, "%d ", BIL.SPH.ccdwy);
645  fprintf(fff, "%d ", BIL.SPH.ccdsx);
646  fprintf(fff, "%d ", BIL.SPH.ccdsy);
647  fprintf(fff, "%d ", BIL.SPH.ccdex);
648  fprintf(fff, "%d ", BIL.SPH.ccdey);
649  fprintf(fff, "%d ", BIL.SPH.ccdvb);
650  fprintf(fff, "%d ", BIL.SPH.ccdnr);
651  fprintf(fff, "%d ", BIL.SPH.dummy1);
652  fprintf(fff, "%d ", BIL.SPH.dummy2);
653  fprintf(fff, "%d ", BIL.SPH.dummy3);
654  fprintf(fff, "%d\n", BIL.SPH.dummy4);
655  fprintf(fff, "%s\n", BIL.SPH.comment);
656 
657 
658 }
struct ddate DATE
Definition: bildef.h:134
char comment[255]
Definition: bildef.h:157
unsigned int ccdmax
Definition: bildef.h:142
unsigned int altitude
Altitude of the Station.
Definition: bildef.h:131
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
unsigned char ti_hour
Definition: bildef.h:79
bil BIL
Definition: Utils.c:27
unsigned char ti_sec
Definition: bildef.h:81
char filpos[5]
Definition: bildef.h:139
char mirpos[8]
Definition: bildef.h:137
struct dtime TIME
Definition: bildef.h:133
float ccdtexp
Definition: bildef.h:140
unsigned char ti_min
Definition: bildef.h:78
float longitude
Longitude of the Station.
Definition: bildef.h:130
unsigned char da_mon
Definition: bildef.h:86
float latitude
Latitude of the Station.
Definition: bildef.h:129
unsigned char da_day
Definition: bildef.h:85
char location[4]
Name of the Station (BLQ, LPA, EVR, TNB, DMC.....)
Definition: bildef.h:128
short int da_year
Definition: bildef.h:84
float ccdtemp
Definition: bildef.h:141
unsigned int ccdmin
Definition: bildef.h:143
float sza
Solar Zenith Angle.
Definition: bildef.h:132
+ Here is the caller graph for this function:

§ D_PrintBILSPH()

void D_PrintBILSPH ( FILE *  fff)

Print Header.

Parameters
*fffASCII file number

Definition at line 581 of file Utils.c.

References spectrumheader::altitude, spectrumheader::ccdex, spectrumheader::ccdey, spectrumheader::ccdmax, spectrumheader::ccdmin, spectrumheader::ccdnr, spectrumheader::ccdsx, spectrumheader::ccdsy, spectrumheader::ccdtemp, spectrumheader::ccdtexp, spectrumheader::ccdvb, spectrumheader::ccdwx, spectrumheader::ccdwy, spectrumheader::comment, ddate::da_day, ddate::da_mon, ddate::da_year, spectrumheader::DATE, spectrumheader::dummy1, spectrumheader::dummy2, spectrumheader::dummy3, spectrumheader::dummy4, spectrumheader::filpos, spectrumheader::imgtype, spectrumheader::latitude, spectrumheader::location, spectrumheader::longitude, spectrumheader::mirpos, bil::SPH, spectrumheader::sza, dtime::ti_hour, dtime::ti_min, dtime::ti_sec, spectrumheader::TIME, and spectrumheader::wavelen.

Referenced by DT_CorrFileEvora(), DT_CorrHeader(), and WriteDataFile().

582 {
583 
584  fprintf(fff, "LOC: %s ", BIL.SPH.location); //Name of the station
585  fprintf(fff, "LAT: %.2lf ", BIL.SPH.latitude);//Station latitude
586  fprintf(fff, "LON: %.2lf ", BIL.SPH.longitude);//Station latitude
587  fprintf(fff, "ALT[m/asl]: %u ", BIL.SPH.altitude);//Station altitude
588  fprintf(fff, "SZA: %.2lf\n", BIL.SPH.sza);//SZA
589 
590  fprintf(fff, "%d/%02d/%02d ", BIL.SPH.DATE.da_year, BIL.SPH.DATE.da_mon, BIL.SPH.DATE.da_day);
591  fprintf(fff, "%02d:%02d:%02d LT ",BIL.SPH.TIME.ti_hour, BIL.SPH.TIME.ti_min,BIL.SPH.TIME.ti_sec);
592  fprintf(fff, "%s ", BIL.SPH.mirpos);
593  fprintf(fff, "%d ", BIL.SPH.wavelen);
594  fprintf(fff, "%s ", BIL.SPH.filpos);
595  fprintf(fff, "%.2lf ", BIL.SPH.ccdtemp);
596  fprintf(fff, "%.2lf ", BIL.SPH.ccdtexp);
597  fprintf(fff, "%5u ", BIL.SPH.ccdmax);
598  fprintf(fff, "%5u\n", BIL.SPH.ccdmin);
599 
600 
601  // Image format
602  fprintf(fff, "%d ", BIL.SPH.imgtype);
603  fprintf(fff, "%d ", BIL.SPH.ccdwx);
604  fprintf(fff, "%d ", BIL.SPH.ccdwy);
605  fprintf(fff, "%d ", BIL.SPH.ccdsx);
606  fprintf(fff, "%d ", BIL.SPH.ccdsy);
607  fprintf(fff, "%d ", BIL.SPH.ccdex);
608  fprintf(fff, "%d ", BIL.SPH.ccdey);
609  fprintf(fff, "%d ", BIL.SPH.ccdvb);
610  fprintf(fff, "%d ", BIL.SPH.ccdnr);
611  fprintf(fff, "%d ", BIL.SPH.dummy1);
612  fprintf(fff, "%d ", BIL.SPH.dummy2);
613  fprintf(fff, "%d ", BIL.SPH.dummy3);
614  fprintf(fff, "%d\n", BIL.SPH.dummy4);
615  fprintf(fff, "%s\n", BIL.SPH.comment);
616 
617 
618 }
struct ddate DATE
Definition: bildef.h:134
char comment[255]
Definition: bildef.h:157
unsigned int ccdmax
Definition: bildef.h:142
unsigned int altitude
Altitude of the Station.
Definition: bildef.h:131
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
unsigned char ti_hour
Definition: bildef.h:79
bil BIL
Definition: Utils.c:27
unsigned char ti_sec
Definition: bildef.h:81
char filpos[5]
Definition: bildef.h:139
char mirpos[8]
Definition: bildef.h:137
struct dtime TIME
Definition: bildef.h:133
float ccdtexp
Definition: bildef.h:140
unsigned char ti_min
Definition: bildef.h:78
float longitude
Longitude of the Station.
Definition: bildef.h:130
unsigned char da_mon
Definition: bildef.h:86
float latitude
Latitude of the Station.
Definition: bildef.h:129
unsigned char da_day
Definition: bildef.h:85
char location[4]
Name of the Station (BLQ, LPA, EVR, TNB, DMC.....)
Definition: bildef.h:128
short int da_year
Definition: bildef.h:84
float ccdtemp
Definition: bildef.h:141
unsigned int ccdmin
Definition: bildef.h:143
float sza
Solar Zenith Angle.
Definition: bildef.h:132
+ Here is the caller graph for this function:

§ D_PrintBILSPH_BIN()

void D_PrintBILSPH_BIN ( int  fd)

Print on file the binary header of the measured spectrum.

Parameters
fdnumber of destination file

Definition at line 540 of file Utils.c.

References spectrumheader::altitude, spectrumheader::ccdex, spectrumheader::ccdey, spectrumheader::ccdmax, spectrumheader::ccdnr, spectrumheader::ccdsx, spectrumheader::ccdsy, spectrumheader::ccdtemp, spectrumheader::ccdtexp, spectrumheader::ccdvb, spectrumheader::ccdwx, spectrumheader::ccdwy, spectrumheader::comment, spectrumheader::DATE, spectrumheader::dummy1, spectrumheader::dummy2, spectrumheader::dummy3, spectrumheader::dummy4, spectrumheader::filpos, spectrumheader::imgtype, spectrumheader::latitude, spectrumheader::location, spectrumheader::longitude, spectrumheader::mirpos, bil::SPH, spectrumheader::sza, spectrumheader::TIME, and spectrumheader::wavelen.

Referenced by WriteDataFile().

541 {
542 
543 
544  unsigned long info = 0;
545 
546 
547  info =0;
548 
549  info += write(fd, BIL.SPH.location, sizeof(BIL.SPH.location));
550  info += write(fd, &BIL.SPH.latitude, sizeof(BIL.SPH.latitude));
551  info += write(fd, &BIL.SPH.longitude, sizeof(BIL.SPH.longitude));
552  info += write(fd, &BIL.SPH.altitude, sizeof(BIL.SPH.altitude));
553  info += write(fd, &BIL.SPH.sza, sizeof(BIL.SPH.sza));
554  info += write(fd, &BIL.SPH.DATE, sizeof(struct ddate));
555  info += write(fd, &BIL.SPH.TIME, sizeof(struct dtime));
556 
557  info += write(fd, BIL.SPH.mirpos, sizeof(BIL.SPH.mirpos));
558  info += write(fd, &BIL.SPH.wavelen, sizeof(BIL.SPH.wavelen));
559  info += write(fd, BIL.SPH.filpos, sizeof(BIL.SPH.filpos));
560 
561  info += write(fd, &BIL.SPH.ccdtemp, sizeof(BIL.SPH.ccdtemp));
562  info += write(fd, &BIL.SPH.ccdtexp, sizeof(BIL.SPH.ccdtexp));
563  info += write(fd, &BIL.SPH.ccdmax, sizeof(BIL.SPH.ccdmax));
564 
565  info += write(fd, &BIL.SPH.imgtype, sizeof(BIL.SPH.imgtype));
566  info += write(fd, &BIL.SPH.ccdwx, sizeof(BIL.SPH.ccdwx));
567  info += write(fd, &BIL.SPH.ccdwy, sizeof(BIL.SPH.ccdwy));
568  info += write(fd, &BIL.SPH.ccdsx, sizeof(BIL.SPH.ccdsx));
569  info += write(fd, &BIL.SPH.ccdsy, sizeof(BIL.SPH.ccdsy));
570  info += write(fd, &BIL.SPH.ccdex, sizeof(BIL.SPH.ccdex));
571  info += write(fd, &BIL.SPH.ccdey, sizeof(BIL.SPH.ccdey));
572  info += write(fd, &BIL.SPH.ccdvb, sizeof(BIL.SPH.ccdvb));
573  info += write(fd, &BIL.SPH.ccdnr, sizeof(BIL.SPH.ccdnr));
574  info += write(fd, &BIL.SPH.dummy1, sizeof(BIL.SPH.dummy1));
575  info += write(fd, &BIL.SPH.dummy2, sizeof(BIL.SPH.dummy2));
576  info += write(fd, &BIL.SPH.dummy3, sizeof(BIL.SPH.dummy3));
577  info += write(fd, &BIL.SPH.dummy4, sizeof(BIL.SPH.dummy4));
578  info += write(fd, &BIL.SPH.comment, sizeof(BIL.SPH.comment));
579 
580 }
struct ddate DATE
Definition: bildef.h:134
char comment[255]
Definition: bildef.h:157
unsigned int ccdmax
Definition: bildef.h:142
Definition: bildef.h:83
unsigned int altitude
Altitude of the Station.
Definition: bildef.h:131
Definition: Dildef.h:423
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
bil BIL
Definition: Utils.c:27
char filpos[5]
Definition: bildef.h:139
char mirpos[8]
Definition: bildef.h:137
struct dtime TIME
Definition: bildef.h:133
Definition: bildef.h:77
float ccdtexp
Definition: bildef.h:140
float longitude
Longitude of the Station.
Definition: bildef.h:130
float latitude
Latitude of the Station.
Definition: bildef.h:129
char location[4]
Name of the Station (BLQ, LPA, EVR, TNB, DMC.....)
Definition: bildef.h:128
float ccdtemp
Definition: bildef.h:141
float sza
Solar Zenith Angle.
Definition: bildef.h:132
+ Here is the caller graph for this function:

§ D_PrintSpectrum()

void D_PrintSpectrum ( FILE *  fff)

Print Spectrum.

Parameters
*fffASCII file number

Definition at line 517 of file Utils.c.

References bil::DPLOT, IDX, IDY, and d_view::ImatGraf.

Referenced by DT_CorrFileEvora(), and DT_CorrHeader().

518 {
519 
520  int x, y;
521 
522  for(y = 0; y < IDY; y++)
523  {
524  for(x = 0; x < IDX; x++)
525  {
526  if((x % 10) == 0)
527  {
528  if(y == 0 && x == 0)
529  {
530  }
531  else
532  fprintf(fff, "\n", NULL);
533  }
534  fprintf(fff, "%5u ", BIL.DPLOT.ImatGraf[y * IDX + x]);
535  }
536  }
537  fprintf(fff, "\n", NULL);
538 
539 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
bil BIL
Definition: Utils.c:27
d_view DPLOT
Definition: bildef.h:254
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
unsigned short * ImatGraf
Definition: bildef.h:176
+ Here is the caller graph for this function:

§ D_VRange()

void D_VRange ( char *  str,
int  val,
int  r,
int  g,
int  b 
)

Create and display the status bar.

Parameters
*strstring as title of the status bar
valvalue of the progressive index
rred color id (0-255)
ggreen color id (0-255)
bblu color id (0-255)

Definition at line 206 of file Utils.c.

References D_CloseVR(), D_VOpen, D_VRip, palette::DB_BG, HELV_SMALL, MCreateShell(), MCreateStatusBar(), MLoopWhileEvents(), MObjectResize(), MObjectSetBackgroundRGB(), MObjectSetCompositeHeight(), MObjectSetText(), MShellDestroy(), MShellRealize(), MShellSetWMCloseCallback(), MShellUnrealize(), MStatusBarSetPos(), MStatusBarSetSliderRGB(), SF_NO_MAXIMIZE, SF_NO_MINIMIZE, and SF_SAVEUNDER.

Referenced by AMS_DoPos(), D_Homing(), D_Positioning(), DB_CalcFluxI(), DB_Column(), DB_MirrorX(), DB_ScanMaxMin(), DemoInitMotor(), DT_CorrFileEvora(), DT_CorrHeader(), EleDatOrBinFormat(), HomeAzimFast(), HomeFiltersFast(), HomeNDFiltersFast(), and HomeTrack().

207 {
208  char msg[16];
209  static MOBJECT sts[16], shell[16];
210  if(D_VRip < 0 && val == 100)
211  return;
212  if(D_VRip < 0 && val > 0)
213  return;
214  if(val == 0)
215  {
216  if(D_VOpen) return;
217  D_VOpen = 1;
218  D_VRip++;
221  sts[D_VRip] = MCreateStatusBar(shell[D_VRip], " 0 %", 100, HELV_SMALL);
223  MStatusBarSetSliderRGB(sts[D_VRip], r, g, b);
225 
227  //MShellRealizeXY(shell[D_VRip], ShLoc[1][0], ShLoc[1][1]);
228  MShellRealize(shell[D_VRip]);
229  MObjectResize(shell[D_VRip], 300, 35);
230  // Chiama MGUI per modificare size shell
231  MLoopWhileEvents(0);
232 
233  }
234  else
235  {
236  if(val == 100)
237  {
238  MShellUnrealize(shell[D_VRip]);
239  MShellDestroy(shell[D_VRip]);
240  D_VRip--;
241  D_VOpen = 0;
242  }
243  else
244  {
245  sprintf(msg, "%d %%", val);
246  MObjectSetText(sts[D_VRip], msg);
247  MStatusBarSetPos(sts[D_VRip], val);
248 
249  }
250  MLoopWhileEvents(0);
251 
252  }
253 }
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
int D_VRip
Definition: Utils.c:148
palette DPAL
Definition: Utils.c:28
void MLoopWhileEvents(int discard)
void MShellRealize(MOBJECT obj)
#define SF_NO_MAXIMIZE
Definition: Mguidefs.h:1034
void MStatusBarSetPos(MOBJECT p, int pos)
int D_VOpen
Definition: Utils.c:148
#define SF_NO_MINIMIZE
Definition: Mguidefs.h:1036
void MShellUnrealize(MOBJECT obj)
void MObjectSetText(MOBJECT obj, const char *text)
void MShellDestroy(MOBJECT obj)
MOBJECT MCreateStatusBar(MOBJECT parent, const char *text, int max, MTFont font)
void MObjectSetCompositeHeight(MOBJECT obj, int h)
#define HELV_SMALL
Definition: Mguidefs.h:881
void MStatusBarSetSliderRGB(MOBJECT p, int r, int g, int b)
MOBJECT MCreateShell(const char *title, int flags)
short DB_BG[3]
Default Background Color.
#define SF_SAVEUNDER
Definition: Mguidefs.h:1015
void * MOBJECT
Definition: Mguidefs.h:192
void MShellSetWMCloseCallback(MOBJECT p, WM_CLOSE_CB cb, void *a_data)
void D_CloseVR(MOBJECT p, void *od, void *ad)
Callback closing the status bar.
Definition: Utils.c:140
void MObjectResize(MOBJECT obj, int w, int h)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_VRangeSim()

void D_VRangeSim ( int  id,
char *  str,
int  val,
int  r,
int  g,
int  b,
int  x,
int  y 
)

init progress bar during simultaneous positioning

Definition at line 258 of file Utils.c.

References D_CloseVR(), palette::DB_BG, DD_VOpen, DD_VRip, HELV_SMALL, MCreateShell(), MCreateStatusBar(), MLoopWhileEvents(), MObjectResize(), MObjectSetBackgroundRGB(), MObjectSetCompositeHeight(), MObjectSetText(), MShellDestroy(), MShellRealizeXY(), MShellSetWMCloseCallback(), MShellUnrealize(), MStatusBarSetPos(), MStatusBarSetSliderRGB(), SF_NO_MAXIMIZE, SF_NO_MINIMIZE, and SF_SAVEUNDER.

Referenced by SD_PosAADev(), SD_Position(), and SD_PosOMUDev().

259 {
260  char msg[16];
261  static MOBJECT sts[16][16], shell[16][16];
262  if(DD_VRip[id] < 0 && val == 100)
263  return;
264  if(DD_VRip[id] < 0 && val > 0)
265  return;
266  if(val == 0)
267  {
268  if(DD_VOpen[id]) return;
269  DD_VOpen[id] = 1;
270  DD_VRip[id]++;
272  MObjectSetBackgroundRGB(shell[id][DD_VRip[id]], DPAL.DB_BG[0], DPAL.DB_BG[1], DPAL.DB_BG[2]);
273  sts[id][DD_VRip[id]] = MCreateStatusBar(shell[id][DD_VRip[id]], " 0 %", 100, HELV_SMALL);
274  MObjectSetBackgroundRGB(sts[id][DD_VRip[id]], DPAL.DB_BG[0], DPAL.DB_BG[1], DPAL.DB_BG[2]);
275  MStatusBarSetSliderRGB(sts[id][DD_VRip[id]], r, g, b);
276  MObjectSetCompositeHeight(sts[id][DD_VRip[id]], 20);
277 
278  MShellSetWMCloseCallback(shell[id][DD_VRip[id]], D_CloseVR, 0L);
279  MShellRealizeXY(shell[id][DD_VRip[id]], x, y);
280  MObjectResize(shell[id][DD_VRip[id]], 300, 35);
281  // Chiama MGUI per modificare size shell
282  MLoopWhileEvents(0);
283 
284  }
285  else
286  {
287  if(val >= 100)
288  {
289  MShellUnrealize(shell[id][DD_VRip[id]]);
290  MShellDestroy(shell[id][DD_VRip[id]]);
291  DD_VRip[id]--;
292  DD_VOpen[id] = 0;
293  }
294  else
295  {
296  sprintf(msg, "%d %%", val);
297  MObjectSetText(sts[id][DD_VRip[id]], msg);
298  MStatusBarSetPos(sts[id][DD_VRip[id]], val);
299  }
300  }
301 }
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
palette DPAL
Definition: Utils.c:28
void MLoopWhileEvents(int discard)
#define SF_NO_MAXIMIZE
Definition: Mguidefs.h:1034
void MStatusBarSetPos(MOBJECT p, int pos)
#define SF_NO_MINIMIZE
Definition: Mguidefs.h:1036
void MShellUnrealize(MOBJECT obj)
void MObjectSetText(MOBJECT obj, const char *text)
void MShellDestroy(MOBJECT obj)
MOBJECT MCreateStatusBar(MOBJECT parent, const char *text, int max, MTFont font)
void MObjectSetCompositeHeight(MOBJECT obj, int h)
#define HELV_SMALL
Definition: Mguidefs.h:881
void MStatusBarSetSliderRGB(MOBJECT p, int r, int g, int b)
void MShellRealizeXY(MOBJECT obj, int x, int y)
MOBJECT MCreateShell(const char *title, int flags)
short DB_BG[3]
Default Background Color.
#define SF_SAVEUNDER
Definition: Mguidefs.h:1015
void * MOBJECT
Definition: Mguidefs.h:192
int DD_VOpen[16]
Definition: Utils.c:151
int DD_VRip[16]
Definition: Utils.c:150
void MShellSetWMCloseCallback(MOBJECT p, WM_CLOSE_CB cb, void *a_data)
void D_CloseVR(MOBJECT p, void *od, void *ad)
Callback closing the status bar.
Definition: Utils.c:140
void MObjectResize(MOBJECT obj, int w, int h)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_CalcFluxI()

int DB_CalcFluxI ( char *  nomefile)

Definition at line 328 of file Utils.c.

References AllocUSMat(), CalcFluxIndex(), spectrumheader::ccdtexp, D_VRange(), ddate::da_day, ddate::da_mon, ddate::da_year, spectrumheader::DATE, bil::DFILEM, bil::DPLOT, IDX, IDY, d_view::ImatGraf, spectrumheader::mirpos, MLoopWhileEvents(), O_BINARY, ReadHeader_BIN(), ReadIMG_BIN(), SAVECNT, bil::SPH, dtime::ti_hour, dtime::ti_min, dtime::ti_sec, spectrumheader::TIME, spectrumheader::wavelen, and d_fileman::WORKDIRECTORY.

Referenced by DT_FluxIndex(), and FluxIndexCB().

329 {
330 
331  FILE *fs;
332  FILE *fd;
333  char buf[512],str[512];
334  int er = 0, i, k;
335  char string[4] = ".FIN";
336  int fb;
337  double fluxindex;
338  char filedatan[256];
339  long numspettri;
340 
341 
342 // Lettura file elenco
343  i=0;
344  fs = fopen(nomefile, "r");
345  if(fs < 0) return 1;
346  while( !feof( fs ) )
347  {
348  fgets(str, 80, fs);
349  i++;
350  }
351  fclose(fs);
352 
353  numspettri = i * SAVECNT;
354 
355  D_VRange("Flux Index Calculation",0, 0, 222, 235);
356 
357 
358  fs = fopen(nomefile, "r");
359  if(fs < 0) return 2;
360 
361  //Read the file names
362  k = 0;
363  while( !feof( fs ) )
364  {
365  fscanf(fs, "%s", filedatan);
366  // build the complete file name
367 // strcpy(buf, BIL.DFILEM.WORKDIRECTORY);
368  strcat(buf, filedatan);
369 
370 
371  fb = open(filedatan, O_RDONLY | O_BINARY, S_IREAD );
372 
373  while( !eof( fb ) )
374  {
375 
376  MLoopWhileEvents(2);
377  k ++;
378  if((k % 10) == 0 && k > 0)
379  D_VRange(NULL, (long) k * 100 / numspettri, 0, 222, 235 );
380  er = ReadHeader_BIN(fb);
381 
382  if(BIL.DPLOT.ImatGraf == 0)
384 
386 
387  if( (strcmp(BIL.SPH.mirpos,"HorizDX") == 0) | (strcmp(BIL.SPH.mirpos,"Zenith") == 0) )
388  {
389  //Filter Data
390  //if (BIL.SPH.ccdwx - (BIL.SPH.ccdex +1) != 0) // se i pixel del sensore sono piu' di quelli in param.ini
391  // BlindPix_1 = BIL.SPH.ccdwx - (BIL.SPH.ccdex +1) ;
392 
393  //FilterData(BIL.DPLOT.ImatGraf, IDX, IDY, 15, BlindPix_1);
394 
395 
396  fluxindex = CalcFluxIndex( BIL.DPLOT.ImatGraf, IDX , IDY/2, (float)BIL.SPH.ccdtexp);
397 
398  sprintf(buf,"%d.FIN", BIL.SPH.wavelen);
399  strcpy(str, BIL.DFILEM.WORKDIRECTORY);
400  strcat(str,buf);
401  //MMessageDialog("Full FileName:", str, "ok", NULL);
402 
403  fd = fopen(str, "a");
404  if(fd < 0) return 1;
405 
406  sprintf(str,"%d/%02d/%02d %02d:%02d:%02d %d %lf\n", BIL.SPH.DATE.da_year, BIL.SPH.DATE.da_mon, BIL.SPH.DATE.da_day, BIL.SPH.TIME.ti_hour, BIL.SPH.TIME.ti_min, BIL.SPH.TIME.ti_sec, BIL.SPH.wavelen, fluxindex);
407  fprintf(fd, "%s", str);
408 
409  fclose(fd);
410  }
411 
412 
413 
414  }
415 // D_VRange(NULL, 100, 128, 254, 128);
416  close (fb);
417 
418 
419 
420  }
421 
422  D_VRange(NULL, 100, 0,0,0);
423 
424  fclose(fs);
425 
426  return 0;
427 }
struct ddate DATE
Definition: bildef.h:134
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
void MLoopWhileEvents(int discard)
#define O_BINARY
Definition: Dildef.h:201
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
void D_VRange(char *str, int val, int r, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
unsigned char ti_hour
Definition: bildef.h:79
bil BIL
Definition: Utils.c:27
d_fileman DFILEM
Definition: bildef.h:257
#define SAVECNT
maximum number of spectra in one file
unsigned char ti_sec
Definition: bildef.h:81
d_view DPLOT
Definition: bildef.h:254
int ReadHeader_BIN(int fd)
read the BINARY header of the stored spectrum
Definition: Spat_Plot.c:1798
char mirpos[8]
Definition: bildef.h:137
struct dtime TIME
Definition: bildef.h:133
void ReadIMG_BIN(int fd, unsigned short *mat, int hp, int vp)
read the BINARY stored spectrum
Definition: Spat_Plot.c:1166
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
double CalcFluxIndex(unsigned short mis[], int dx, int dy, float te)
calculates the Flux Index of a measurement
Definition: Utils.c:306
unsigned short * ImatGraf
Definition: bildef.h:176
float ccdtexp
Definition: bildef.h:140
unsigned char ti_min
Definition: bildef.h:78
unsigned char da_mon
Definition: bildef.h:86
char WORKDIRECTORY[_MAX_PATH]
Definition: bildef.h:202
unsigned char da_day
Definition: bildef.h:85
short int da_year
Definition: bildef.h:84
unsigned short * AllocUSMat(int hp, int vp)
Definition: Spat_Plot.c:1994
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DD_VRange()

void __stdcall DD_VRange ( const char *  str,
int  val,
int  Port 
)

Definition at line 153 of file Utils.c.

References D_CloseVR(), D_VOpen, D_VRip, palette::DB_BG, HELV_SMALL, MCreateShell(), MCreateStatusBar(), MLoopWhileEvents(), MObjectResize(), MObjectSetBackgroundRGB(), MObjectSetCompositeHeight(), MObjectSetText(), MShellDestroy(), MShellRealize(), MShellSetWMCloseCallback(), MShellUnrealize(), MStatusBarSetPos(), MStatusBarSetSliderRGB(), SF_NO_MAXIMIZE, SF_NO_MINIMIZE, and SF_SAVEUNDER.

Referenced by DB_InitCamera().

154 {
155 
156 
157  char msg[16];
158  static MOBJECT sts[16], shell[16];
159  if(D_VRip < 0 && val == 100)
160  return;
161  if(D_VRip < 0 && val > 0)
162  return;
163  if(val == 0)
164  {
165  if(D_VOpen) return;
166  D_VOpen = 1;
167  D_VRip++;
170  sts[D_VRip] = MCreateStatusBar(shell[D_VRip], " 0 %", 100, HELV_SMALL);
172  MStatusBarSetSliderRGB(sts[D_VRip], 0, 255, 0);
174 
176  //MShellRealizeXY(shell[D_VRip], ShLoc[1][0], ShLoc[1][1]);
177  MShellRealize(shell[D_VRip]);
178  MObjectResize(shell[D_VRip], 300, 35);
179  // Chiama MGUI per modificare size shell
180  MLoopWhileEvents(0);
181 
182  }
183  else
184  {
185  if(val == 100)
186  {
187  MShellUnrealize(shell[D_VRip]);
188  MShellDestroy(shell[D_VRip]);
189  D_VRip--;
190  D_VOpen = 0;
191  }
192  else
193  {
194  sprintf(msg, "%d %%", val);
195  MObjectSetText(sts[D_VRip], msg);
196  MStatusBarSetPos(sts[D_VRip], val);
197  }
198  }
199 }
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
int D_VRip
Definition: Utils.c:148
palette DPAL
Definition: Utils.c:28
void MLoopWhileEvents(int discard)
void MShellRealize(MOBJECT obj)
#define SF_NO_MAXIMIZE
Definition: Mguidefs.h:1034
void MStatusBarSetPos(MOBJECT p, int pos)
int D_VOpen
Definition: Utils.c:148
#define SF_NO_MINIMIZE
Definition: Mguidefs.h:1036
void MShellUnrealize(MOBJECT obj)
void MObjectSetText(MOBJECT obj, const char *text)
void MShellDestroy(MOBJECT obj)
MOBJECT MCreateStatusBar(MOBJECT parent, const char *text, int max, MTFont font)
void MObjectSetCompositeHeight(MOBJECT obj, int h)
#define HELV_SMALL
Definition: Mguidefs.h:881
void MStatusBarSetSliderRGB(MOBJECT p, int r, int g, int b)
MOBJECT MCreateShell(const char *title, int flags)
short DB_BG[3]
Default Background Color.
#define SF_SAVEUNDER
Definition: Mguidefs.h:1015
void * MOBJECT
Definition: Mguidefs.h:192
void MShellSetWMCloseCallback(MOBJECT p, WM_CLOSE_CB cb, void *a_data)
void D_CloseVR(MOBJECT p, void *od, void *ad)
Callback closing the status bar.
Definition: Utils.c:140
void MObjectResize(MOBJECT obj, int w, int h)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DT_ColFormat()

int DT_ColFormat ( void  )

Callback for Column format.

Definition at line 431 of file Utils.c.

References _MAX_PATH, FB_PREFS::allow_dir_create, FB_PREFS::allow_dir_delete, FB_PREFS::allow_dir_rename, FB_PREFS::bg_image_file, FB_PREFS::button_font, FB_PREFS::change_cwd, DAS, d_fileman::DATADIRECTORY, DB_Column(), d_fileman::DBFILENAME, bil::DFILEM, das::DOption, False, FB_PREFS::font, HELV_SMALL, d_fileman::HOMEDIRECTORY, MFileBrowseExt(), optionini::savingmode, FB_PREFS::transparent_tree, and True.

Referenced by ColumnFormatCB().

432 {
433 
434  int er =0;
435  char fname[128];
436  char buff[_MAX_PATH];
437 // int l;
438 
439 
440  FB_PREFS fbp;
441 
442  fname[0] = '\0';
443  buff[0] = '\0';
444 
445  memset (&fbp, 0, sizeof (fbp));
446 
447  fbp.change_cwd = True;
448  fbp.allow_dir_create = True;
449  fbp.allow_dir_rename = True;
450  fbp.allow_dir_delete = True;
451  fbp.transparent_tree = False;
452  fbp.font = HELV_SMALL;
453  fbp.button_font = HELV_SMALL;
454  //Set Img file
455  sprintf(buff, "%s\\%s", BIL.DFILEM.HOMEDIRECTORY, "sys\\Tile2.bmp" );
456  fbp.bg_image_file =buff;
457 
458 /*
459  BIL.DFILEM.DBFILENAME[0] = 0;
460 
461  MDCreateFM_Shell(FOPEN, FDAT); //Open File, Dat ext.
462 
463  if(BIL.DFILEM.DBFILENAME[0] == 0)
464  return 1;
465 
466  DB_Column(BIL.DFILEM.DBFILENAME);
467 */
468 
470  er = MFileBrowseExt ("Select File for Column Format", "*.bif", fname, BIL.DFILEM.DATADIRECTORY, &fbp);
471  else
472  er = MFileBrowseExt ("Select File for column Format", "*.dat", fname, BIL.DFILEM.DATADIRECTORY, &fbp);
473  if(er)
474  {
475  sprintf(BIL.DFILEM.DBFILENAME,"%s%s",BIL.DFILEM.DATADIRECTORY, fname);
476  //l = strlen(fname);
477  //strncpy(buff, fname+l-4, 4);
478 
479  //if( (strcmp(fname+l-4,".dat") == 0) |(strcmp(fname+l-4,".Dat") == 0) )
480  // BIL.DFILEM.FKIND = FDAT;
481  //else if( (strcmp(fname+l-4,".bif") == 0) | (strcmp(fname+l-4,".Bif") == 0) )
482  // BIL.DFILEM.FKIND = FBIF;
483  //else
484  //{
485  // MMessageDialog("DAS information", "Unsupported format!!", " Ok ", NULL);
486  // return 1;
487  //}
489  }
490  else
491  return 1;
492 
493 
494  return 0;
495 
496 }
optionini DOption
Options for DAS execution.
int savingmode
Flag to set saving mode: 0=ASCII, 1=Binary.
CARD8 change_cwd
Definition: Mguidefs.h:1485
CARD8 allow_dir_create
Definition: Mguidefs.h:1487
MTFont button_font
Definition: Mguidefs.h:1501
CARD8 allow_dir_delete
Definition: Mguidefs.h:1493
char HOMEDIRECTORY[_MAX_PATH]
Definition: bildef.h:200
MTFont font
Definition: Mguidefs.h:1499
#define False
Definition: Mguidefs.h:236
das DAS
Definition: Chktemp.c:26
char DATADIRECTORY[_MAX_PATH]
Definition: bildef.h:201
bil BIL
Definition: Utils.c:27
File Browser Preferences. Used by the Utility functions MFileBowserExt() and MDirBowserExt().
Definition: Mguidefs.h:1482
CARD8 transparent_tree
Definition: Mguidefs.h:1495
d_fileman DFILEM
Definition: bildef.h:257
#define HELV_SMALL
Definition: Mguidefs.h:881
char DBFILENAME[_MAX_PATH]
Definition: bildef.h:204
int MFileBrowseExt(const char *t, const char *ext, char *fname, char *dname, FB_PREFS *prefs)
const char * bg_image_file
Definition: Mguidefs.h:1519
#define _MAX_PATH
Definition: Dildef.h:202
#define True
Definition: Mguidefs.h:235
CARD8 allow_dir_rename
Definition: Mguidefs.h:1490
int DB_Column(char *sourcefilename)
Column format.
Definition: Save.c:1109
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DT_CorrFileEvora()

int DT_CorrFileEvora ( void  )

Used to correct some data files.

Definition at line 786 of file Utils.c.

References AllocUSMat(), spectrumheader::ccdex, spectrumheader::ccdey, spectrumheader::ccdsx, spectrumheader::ccdsy, spectrumheader::ccdwx, spectrumheader::ccdwy, D_PrintBILSPH(), D_PrintSpectrum(), D_VRange(), d_fileman::DBFILENAME, DeallocUSMat(), bil::DFILEM, bil::DPLOT, FELE, FOPEN, IDX, IDY, d_view::ImatGraf, d_view::ImatOrig, MDCreateFM_Shell(), MLoopWhileEvents(), ReadHeaderOnly(), ReadIMG(), SAVECNT, ShiftImg(), bil::SPH, and d_fileman::WORKDIRECTORY.

787 {
788 
789  FILE *fs, *fd, *fc;
790  char buf[256],str[256];
791  int er = 0, i, k;
792 
793  char filedatan[32];
794  long numspettri;
795 
796 
797  BIL.DFILEM.DBFILENAME[0] = 0;
798  MDCreateFM_Shell(FOPEN, FELE); //Open File, Ele ext.
799 
800  if(BIL.DFILEM.DBFILENAME[0] == 0)
801  return 0;
802 
803 // Lettura file elenco
804  i=0;
805  fs = fopen(BIL.DFILEM.DBFILENAME, "r");
806  if(fs < 0) return 1;
807  //Prima lettura file elenco per determinare approssimativamente in numero di spettri presenti
808  while( !feof( fs ) )
809  {
810  fgets(str, 80, fs);
811  i++;
812  }
813  fclose(fs);
814 
815  numspettri = i * SAVECNT;
816 
817  D_VRange("Header file correction",0, 0, 222, 235);
818 
819 
820  fs = fopen(BIL.DFILEM.DBFILENAME, "r");
821  if(fs < 0) return 1;
822 
823  //Read the file names
824  k = 0;
825  while( !feof( fs ) )
826  {
827  fscanf(fs, "%s", filedatan);
828  // build the complete file name
829  strcpy(buf, BIL.DFILEM.WORKDIRECTORY);
830  strcat(buf, filedatan);
831 
832  fc = fopen(buf, "r");
833  if(fc < 0) return 1;
834 
835  while( !feof( fc ) )
836  {
837  MLoopWhileEvents(0);
838  k ++;
839  if((k % 10) == 0 && k > 0)
840  D_VRange(NULL, (long) k * 100 / numspettri, 0, 222, 235 );
841  er = ReadHeaderOnly(fc);
842  //Modifica alcuni parametri del Header
843  BIL.SPH.ccdwx = 1024;
844  BIL.SPH.ccdwy = 254;
845  BIL.SPH.ccdsx = 0;
846  BIL.SPH.ccdsy = 0;
847  BIL.SPH.ccdex = 1023;
848  BIL.SPH.ccdey = 253;
849 
850 
851  if(BIL.DPLOT.ImatGraf == 0)
853 
854 
855 
856  ReadIMG(fc, BIL.DPLOT.ImatGraf, IDX, IDY);
857 
858 
859  ShiftImg(IDX, IDY);
860 
861 
862  sprintf(buf,"%s\\%s", "CORRECTED",filedatan);
863  strcpy(str, BIL.DFILEM.WORKDIRECTORY);
864  strcat(str,buf);
865  //MMessageDialog("Full FileName:", str, "ok", NULL);
866  fd = fopen(str, "a");
867  if(fd < 0) return 1;
868 
869  //Print
870  D_PrintBILSPH(fd);
871  D_PrintSpectrum(fd);
872 
873  fclose(fd);
874 
875 
876  }
877  fclose(fc);
878 
879  }
880 
881  D_VRange(NULL, 100, 0,0,0);
882 
883  fclose(fs);
884 
885  if(!BIL.DPLOT.ImatGraf == 0)
886  {
889  }
890  return 0;
891 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int ReadHeaderOnly(FILE *fd)
read the ASCII header of the stored spectrum
Definition: Save.c:704
void MLoopWhileEvents(int discard)
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
void ReadIMG(FILE *file, unsigned short *mat, int hp, int vp)
Read ASCII Image (Spectral Data only) .
Definition: Spat_Plot.c:1206
void D_VRange(char *str, int val, int r, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
bil BIL
Definition: Utils.c:27
d_fileman DFILEM
Definition: bildef.h:257
void D_PrintSpectrum(FILE *fff)
Print Spectrum.
Definition: Utils.c:517
#define SAVECNT
maximum number of spectra in one file
unsigned short * ImatOrig
Definition: bildef.h:180
d_view DPLOT
Definition: bildef.h:254
unsigned short * DeallocUSMat(unsigned short *mat)
Definition: Spat_Plot.c:145
char DBFILENAME[_MAX_PATH]
Definition: bildef.h:204
MOBJECT MDCreateFM_Shell(int mod, int fmt)
Definition: DFileMan.c:407
void D_PrintBILSPH(FILE *fff)
Print Header.
Definition: Utils.c:581
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
void ShiftImg(int hp, int vp)
Used to correct some data files.
Definition: Utils.c:765
unsigned short * ImatGraf
Definition: bildef.h:176
#define FOPEN
Definition: bildef.h:217
char WORKDIRECTORY[_MAX_PATH]
Definition: bildef.h:202
#define FELE
Definition: bildef.h:223
unsigned short * AllocUSMat(int hp, int vp)
Definition: Spat_Plot.c:1994
+ Here is the call graph for this function:

§ DT_CorrHeader()

int DT_CorrHeader ( )

Used to correct the header in some data files.

Definition at line 662 of file Utils.c.

References AllocUSMat(), spectrumheader::ccdex, spectrumheader::ccdey, spectrumheader::ccdsx, spectrumheader::ccdsy, spectrumheader::ccdwx, spectrumheader::ccdwy, D_PrintBILSPH(), D_PrintSpectrum(), D_VRange(), d_fileman::DBFILENAME, DeallocUSMat(), bil::DFILEM, bil::DPLOT, FELE, FOPEN, IDX, IDY, d_view::ImatGraf, d_view::ImatOrig, MDCreateFM_Shell(), MLoopWhileEvents(), ReadHeaderOldF(), ReadIMG(), SAVECNT, bil::SPH, and d_fileman::WORKDIRECTORY.

663 {
664 
665  FILE *fs, *fd, *fc;
666  char buf[256],str[256];
667  int er = 0, i, k;
668 
669  char filedatan[32];
670  long numspettri;
671 
672 
673  BIL.DFILEM.DBFILENAME[0] = 0;
674  MDCreateFM_Shell(FOPEN, FELE); //Open File, Ele ext.
675 
676  if(BIL.DFILEM.DBFILENAME[0] == 0)
677  return 0;
678 
679 // Lettura file elenco
680  i=0;
681  fs = fopen(BIL.DFILEM.DBFILENAME, "r");
682  if(fs < 0) return 1;
683  //Prima lettura file elenco per determinare approssimativamente in numero di spettri presenti
684  while( !feof( fs ) )
685  {
686  fgets(str, 80, fs);
687  i++;
688  }
689  fclose(fs);
690 
691  numspettri = i * SAVECNT;
692 
693  D_VRange("Header file correction",0, 0, 222, 235);
694 
695 
696  fs = fopen(BIL.DFILEM.DBFILENAME, "r");
697  if(fs < 0) return 1;
698 
699  //Read the file names
700  k = 0;
701  while( !feof( fs ) )
702  {
703  fscanf(fs, "%s", filedatan);
704  // build the complete file name
705  strcpy(buf, BIL.DFILEM.WORKDIRECTORY);
706  strcat(buf, filedatan);
707 
708  fc = fopen(buf, "r");
709  if(fc < 0) return 1;
710 
711  while( !feof( fc ) )
712  {
713  MLoopWhileEvents(0);
714  k ++;
715  if((k % 10) == 0 && k > 0)
716  D_VRange(NULL, (long) k * 100 / numspettri, 0, 222, 235 );
717  er = ReadHeaderOldF(fc);
718  //Modifica alcuni parametri del Header
719  BIL.SPH.ccdwx = 1024;
720  BIL.SPH.ccdwy = 254;
721  BIL.SPH.ccdsx = 0;
722  BIL.SPH.ccdsy = 0;
723  BIL.SPH.ccdex = 1023;
724  BIL.SPH.ccdey = 253;
725 
726  if(BIL.DPLOT.ImatGraf == 0)
728 
729  ReadIMG(fc, BIL.DPLOT.ImatGraf, IDX, IDY);
730 
731 
732  sprintf(buf,"%s\\%s", "CORRECTED",filedatan);
733  strcpy(str, BIL.DFILEM.WORKDIRECTORY);
734  strcat(str,buf);
735  //MMessageDialog("Full FileName:", str, "ok", NULL);
736  fd = fopen(str, "a");
737  if(fd < 0) return 1;
738 
739  //Print
740  D_PrintBILSPH(fd);
741  D_PrintSpectrum(fd);
742 
743  fclose(fd);
744 
745 
746  }
747  fclose(fc);
748 
749  }
750 
751  D_VRange(NULL, 100, 0,0,0);
752 
753  fclose(fs);
754 
755  if(!BIL.DPLOT.ImatGraf == 0)
756  {
759 
760  }
761  return 0;
762 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
void MLoopWhileEvents(int discard)
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
void ReadIMG(FILE *file, unsigned short *mat, int hp, int vp)
Read ASCII Image (Spectral Data only) .
Definition: Spat_Plot.c:1206
void D_VRange(char *str, int val, int r, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
bil BIL
Definition: Utils.c:27
d_fileman DFILEM
Definition: bildef.h:257
void D_PrintSpectrum(FILE *fff)
Print Spectrum.
Definition: Utils.c:517
#define SAVECNT
maximum number of spectra in one file
unsigned short * ImatOrig
Definition: bildef.h:180
d_view DPLOT
Definition: bildef.h:254
unsigned short * DeallocUSMat(unsigned short *mat)
Definition: Spat_Plot.c:145
char DBFILENAME[_MAX_PATH]
Definition: bildef.h:204
MOBJECT MDCreateFM_Shell(int mod, int fmt)
Definition: DFileMan.c:407
void D_PrintBILSPH(FILE *fff)
Print Header.
Definition: Utils.c:581
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
unsigned short * ImatGraf
Definition: bildef.h:176
#define FOPEN
Definition: bildef.h:217
char WORKDIRECTORY[_MAX_PATH]
Definition: bildef.h:202
#define FELE
Definition: bildef.h:223
unsigned short * AllocUSMat(int hp, int vp)
Definition: Spat_Plot.c:1994
int ReadHeaderOldF(FILE *fd)
read the ASCII header of the stored spectrum (OLD FORMAT - replaced by ReadHeaderOnly(FILE *fd) ...
Definition: Save.c:751
+ Here is the call graph for this function:

§ DT_FluxIndex()

int DT_FluxIndex ( void  )

Callback for Flux Index Calculation.

Definition at line 499 of file Utils.c.

References DB_CalcFluxI(), d_fileman::DBFILENAME, bil::DFILEM, FELE, FOPEN, and MDCreateFM_Shell().

Referenced by DB_ToolsKeyB_CB().

500 {
501 
502 
503 
504  BIL.DFILEM.DBFILENAME[0] = 0;
505  MDCreateFM_Shell(FOPEN, FELE); //Open File, Ele ext.
506 
507  if(BIL.DFILEM.DBFILENAME[0] == 0)
508  return 1;
509 
511 
512 
513 
514  return 0;
515 }
int DB_CalcFluxI(char *nomefile)
Definition: Utils.c:328
bil BIL
Definition: Utils.c:27
d_fileman DFILEM
Definition: bildef.h:257
char DBFILENAME[_MAX_PATH]
Definition: bildef.h:204
MOBJECT MDCreateFM_Shell(int mod, int fmt)
Definition: DFileMan.c:407
#define FOPEN
Definition: bildef.h:217
#define FELE
Definition: bildef.h:223
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DT_LinkSpectra()

int DT_LinkSpectra ( void  )

For the linked spectra (..on going!!!)

Definition at line 915 of file Utils.c.

References d_fileman::DBFILENAME, bil::DFILEM, FMOD, FOPEN, MDCreateFM_Shell(), and Model_read().

Referenced by DB_ToolsKeyB_CB().

916 {
917 
918  BIL.DFILEM.DBFILENAME[0] = 0;
919  MDCreateFM_Shell(FOPEN, FMOD); //Open File, mod ext.
920 
921  if(BIL.DFILEM.DBFILENAME[0] == 0)
922  return 1;
923 
925 
926  return 0;
927 
928 
929 }
#define FMOD
Definition: bildef.h:228
bil BIL
Definition: Utils.c:27
d_fileman DFILEM
Definition: bildef.h:257
char DBFILENAME[_MAX_PATH]
Definition: bildef.h:204
MOBJECT MDCreateFM_Shell(int mod, int fmt)
Definition: DFileMan.c:407
#define FOPEN
Definition: bildef.h:217
int Model_read(char *buff)
Definition: Utils.c:893
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ Model_read()

int Model_read ( char *  buff)

Definition at line 893 of file Utils.c.

References d_fileman::DBFILENAME, and bil::DFILEM.

Referenced by DT_LinkSpectra().

894 {
895 
896  FILE *fs;
897 
898 
899  fs = fopen(BIL.DFILEM.DBFILENAME, "r");
900  if(fs < 0) return 1;
901 
902  while( !feof( fs ) )
903  {
904 // fscanf(fs, "%s", str); //comment
905 
906 
907  }
908 
909 
910  fclose(fs);
911  return 0;
912 }
bil BIL
Definition: Utils.c:27
d_fileman DFILEM
Definition: bildef.h:257
char DBFILENAME[_MAX_PATH]
Definition: bildef.h:204
+ Here is the caller graph for this function:

§ polint()

void polint ( float  xa[],
float  ya[],
int  n,
float  x,
float *  y,
float *  dy 
)

Definition at line 42 of file Utils.c.

References free_vector(), nrerror(), and vector().

Referenced by polintlambda().

43 {
44  int i,m,ns=1;
45  float den,dif,dift,ho,hp,w;
46  float *c,*d;
47  dif=(float)fabs(x-xa[1]);
48  c=vector(1,n);
49  d=vector(1,n);
50  for (i=1;i<=n;i++)
51  { //Here we .nd the index ns of the closest table entry,
52  if((dift=(float)fabs(x-xa[i])) < dif)
53  {
54  ns=i;
55  dif=dift;
56  }
57  c[i]=ya[i]; //and initialize the tableau of c’s and d’s.
58  d[i]=ya[i];
59  }
60  *y=ya[ns--]; //This is the initial approximation to y.
61  for (m=1;m<n;m++)
62  { //For each column of the tableau,
63  for(i=1;i<=n-m;i++)
64  { //we loop over the current c’s and d’s and update them.
65  ho=xa[i]-x;
66  hp=xa[i+m]-x;
67  w=c[i+1]-d[i];
68  if((den=ho-hp) == 0.0) //This error can occur only if two input
69  //xa’s are (to within roundo.) identical.
70  nrerror("Error in routine polint");
71  den=w/den;
72  d[i]=hp*den; //Here the c’s and d’s are updated.
73  c[i]=ho*den;
74  }
75  *y += (*dy=(2*ns < (n-m) ? c[ns+1] : d[ns--]));
76  /*
77  After each column in the tableau is completed, we decide which correction,
78  c or d, we want to add to our accumulating value of y,
79  i.e., which path to take through the tableau forking up or down.
80  We do this in such a way as to take the most straight
81  line route through the tableau to its apex, updating ns accordingly ù to keep track of where we are. This route keeps the partial approximations centered (insofar as possible) on the target x. The last dy added is thus the error indication. */ } free_vector(d,1,n); free_vector(c,1,n); }
82  to keep track of where we are.
83  This route keeps the partial approximations centered (insofar as possible)
84  on the target x. The last dy added is thus the error indication.
85  */
86  }
87  free_vector(d,1,n);
88  free_vector(c,1,n);
89 }
float * vector()
void free_vector()
void nrerror()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ polintlambda()

int polintlambda ( void  )

Definition at line 94 of file Utils.c.

References dvector(), nrerror(), and polint().

95 {
96 
97  int i, l = 1, linit;
98  float dy,y;
99  FILE *nf;
100  float *xa,*ya;
101 
102  xa = (float *)dvector(1,137);
103  ya = (float *)dvector(1,137) ;
104 
105 
106  if((nf = fopen("In.dat", "r")) == NULL)
107  nrerror("In.dat not found\n");
108  while(!feof(nf))
109  {
110  fscanf(nf, "%f%f", &xa[l], &ya[l]);
111  printf("%d %12.6f %12.6f \n", l, xa[l],ya[l]);
112 
113  l++;
114  }
115  fclose(nf);
116  linit = (int) xa[1];
117 
118  nf = fopen("Is.dat", "w");
119 
120  for (i=1; i<l-2;i++)
121  {
122  polint( &xa[i], &ya[i],2,(float) i+linit,&y,&dy);
123  printf("\n%d %12.6f %12.6f ", i, xa[i],ya[i]);
124  printf("\n%d %d %12.6f %12.6f", i, i+linit,y,dy);
125  printf("\n**************");
126 
127  fprintf(nf, "%12.6lf %12.6lf %d %12.6lf \n",xa[i],ya[i], i+linit, y);
128 
129  }
130 
131  fclose(nf);
132 
133  return 0;
134 
135 }
void polint(float xa[], float ya[], int n, float x, float *y, float *dy)
Definition: Utils.c:42
double * dvector()
void nrerror()
+ Here is the call graph for this function:

§ ShiftImg()

void ShiftImg ( int  hp,
int  vp 
)

Used to correct some data files.

Parameters
hphorizontal pixels
vpvertical pixels

Definition at line 765 of file Utils.c.

References bil::DPLOT, IDX, and d_view::ImatGraf.

Referenced by DT_CorrFileEvora().

766 {
767 
768  int x, y;
769 
770  for(y = 0; y < vp; y++)
771  {
772  for(x = 0; x < hp; x++)
773  {
774  if((x==0) & (y!=0))
775  BIL.DPLOT.ImatGraf[y * IDX + x] =BIL.DPLOT.ImatGraf[y * IDX + x+2]/2 + BIL.DPLOT.ImatGraf[y * IDX + x+3]/2;
776  else if((x==1) & (y!=0))
777  BIL.DPLOT.ImatGraf[y * IDX + x] =BIL.DPLOT.ImatGraf[y * IDX + x+1]/2 + BIL.DPLOT.ImatGraf[y * IDX + x+3]/2;
778  else
779  BIL.DPLOT.ImatGraf[y * IDX + x] =BIL.DPLOT.ImatGraf[y * IDX + x];
780  }
781  }
782 
783 
784 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
bil BIL
Definition: Utils.c:27
d_view DPLOT
Definition: bildef.h:254
unsigned short * ImatGraf
Definition: bildef.h:176
+ Here is the caller graph for this function:

Variable Documentation

§ BIL

bil BIL

Definition at line 27 of file Utils.c.

§ D_VOpen

int D_VOpen = 0

Definition at line 148 of file Utils.c.

Referenced by D_VRange(), and DD_VRange().

§ D_VRip

int D_VRip = -1

Definition at line 148 of file Utils.c.

Referenced by D_VRange(), and DD_VRange().

§ DD_VOpen

int DD_VOpen[16]

Definition at line 151 of file Utils.c.

Referenced by D_VRangeSim(), SD_PosAADev(), SD_Position(), and SD_PosOMUDev().

§ DD_VRip

int DD_VRip[16]

Definition at line 150 of file Utils.c.

Referenced by D_VRangeSim().

§ DPAL

palette DPAL

Definition at line 28 of file Utils.c.

______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:47:00 for DAS - Rel. 3.1.6 - 18/09/2017.