Skip to content

Commit

Permalink
Fix gain=0 in fits header
Browse files Browse the repository at this point in the history
  • Loading branch information
pchev committed Sep 19, 2018
1 parent 36e9032 commit 191fee0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/cu_ascomcamera.pas
Original file line number Diff line number Diff line change
Expand Up @@ -988,16 +988,16 @@ procedure T_ascomcamera.SetGain(value: integer);

function T_ascomcamera.GetGain: integer;
begin
result:=0;
result:=NullInt;
{$ifdef mswindows}
if Connected and (FhasGainISO or FhasGain) then begin
try
result:=V.Gain;
except
result:=0;
result:=NullInt;
end;
end
else result:=0;
else result:=NullInt;
{$endif}
end;

Expand Down Expand Up @@ -1113,19 +1113,19 @@ function T_ascomcamera.GetVideoExposure:integer;

function T_ascomcamera.GetVideoGain:integer;
begin
result:=0;
result:=NullInt;
// todo
end;

function T_ascomcamera.GetVideoGamma:integer;
begin
result:=0;
result:=NullInt;
// todo
end;

function T_ascomcamera.GetVideoBrightness:integer;
begin
result:=0;
result:=NullInt;
// todo
end;

Expand Down
16 changes: 8 additions & 8 deletions src/cu_camera.pas
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ procedure T_camera.WriteHeaders;
hbitpix,hnaxis,hnaxis1,hnaxis2,hnaxis3,hbin1,hbin2,cgain,focuserpos: integer;
hfilter,hframe,hinstr,hdateobs : string;
hbzero,hbscale,hdmin,hdmax,hra,hdec,hexp,hpix1,hpix2,hairmass,focusertemp: double;
gamma,offset: double;
gamma,offset: integer;
Frx,Fry,Frwidth,Frheight: integer;
hasfocusertemp,hasfocuserpos: boolean;
begin
Expand Down Expand Up @@ -505,14 +505,14 @@ procedure T_camera.WriteHeaders;
gamma:=GetVideoGamma;
offset:=GetVideoBrightness;
except
gamma:=0;
offset:=0;
gamma:=NullInt;
offset:=NullInt;
end;
try
cgain:=0;
cgain:=NullInt;
if FhasGain then cgain:=GetGain;
except
cgain:=0;
cgain:=NullInt;
end;
try
siso:='';
Expand Down Expand Up @@ -567,10 +567,10 @@ procedure T_camera.WriteHeaders;
Ffits.Header.Add('DATE-OBS',hdateobs,'UTC start date of observation');
if hexp>0 then Ffits.Header.Add('EXPTIME',hexp,'[s] Total Exposure Time');
if FStackCount>1 then Ffits.Header.Add('STACKCNT',FStackCount,'Number of stacked frames');
if cgain>0 then Ffits.Header.Add('GAIN',cgain,'Video gain');
if cgain<>NullInt then Ffits.Header.Add('GAIN',cgain,'Video gain');
if siso<>'' then Ffits.Header.Add('GAIN',siso,'Camera ISO');
if gamma>0 then Ffits.Header.Add('GAMMA',gamma,'Video gamma');
if offset>0 then Ffits.Header.Add('OFFSET',offset,'Video offset,brightness');
if gamma<>NullInt then Ffits.Header.Add('GAMMA',gamma,'Video gamma');
if offset<>NullInt then Ffits.Header.Add('OFFSET',offset,'Video offset,brightness');
if hpix1>0 then Ffits.Header.Add('XPIXSZ',hpix1 ,'[um] Pixel Size X');
if hpix2>0 then Ffits.Header.Add('YPIXSZ',hpix2 ,'[um] Pixel Size Y');
if hbin1>0 then Ffits.Header.Add('XBINNING',hbin1 ,'Binning factor X');
Expand Down
8 changes: 4 additions & 4 deletions src/cu_indicamera.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ procedure T_indicamera.SetGain(value: integer);
function T_indicamera.GetGain: integer;
var i: integer;
begin
result:=0;
result:=NullInt;
if (CCDIso<>nil) and FhasGainISO then begin
for i := 0 to CCDIso.nsp - 1 do
if CCDIso.sp[i].s = ISS_ON then begin
Expand Down Expand Up @@ -1581,23 +1581,23 @@ function T_indicamera.GetVideoExposure:integer;

function T_indicamera.GetVideoGain:integer;
begin
result:=0;
result:=NullInt;
if IGain<>nil then begin
result:=round(IGain.value);
end;
end;

function T_indicamera.GetVideoGamma:integer;
begin
result:=0;
result:=NullInt;
if IGamma<>nil then begin
result:=round(IGamma.value);
end;
end;

function T_indicamera.GetVideoBrightness:integer;
begin
result:=0;
result:=NullInt;
if IBrightness<>nil then begin
result:=round(IBrightness.value);
end;
Expand Down
8 changes: 4 additions & 4 deletions src/fu_video.pas
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

interface

uses u_global, u_utils, UScaleDPI, cu_camera, cu_wheel, indiapi, pu_indigui,
uses u_global, u_utils, UScaleDPI, cu_camera, cu_wheel, indiapi, pu_indigui, math,
Classes, SysUtils, LazFileUtils, Forms, Controls, StdCtrls, ExtCtrls, ComCtrls;

type
Expand Down Expand Up @@ -187,7 +187,7 @@ procedure Tf_video.SetImageControls;
Gain.Max:=round(r.max);
Gain.LineSize:=round(r.step);
Gain.PageSize:=round(5*r.step);
Gain.Position:=camera.VideoGain;
Gain.Position:=max(min(round(camera.VideoGain),Gain.Max),Gain.Min);
end;
r:=camera.VideoGammaRange;
PanelGamma.Visible:=(r.max>0);
Expand All @@ -197,7 +197,7 @@ procedure Tf_video.SetImageControls;
Gamma.Max:=round(r.max);
Gamma.LineSize:=round(r.step);
Gamma.PageSize:=round(5*r.step);
Gamma.Position:=camera.VideoGamma;
Gamma.Position:=max(min(round(camera.VideoGamma),Gamma.Max),Gamma.Min);
end;
r:=camera.VideoBrightnessRange;
PanelBrightness.Visible:=(r.max>0);
Expand All @@ -207,7 +207,7 @@ procedure Tf_video.SetImageControls;
Brightness.Max:=round(r.max);
Brightness.LineSize:=round(r.step);
Brightness.PageSize:=round(5*r.step);
Brightness.Position:=camera.VideoBrightness;
Brightness.Position:=max(min(round(camera.VideoBrightness),Brightness.Max),Brightness.Min);
end;

end;
Expand Down
6 changes: 3 additions & 3 deletions src/pu_main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3331,9 +3331,9 @@ procedure Tf_main.CameraFPSChange(Sender: TObject);
procedure Tf_main.CameraVideoExposureChange(Sender: TObject);
begin
f_video.ShowExposure(round(camera.VideoExposure));
f_video.Gain.Position:=round(camera.VideoGain);
f_video.Gamma.Position:=round(camera.VideoGamma);
f_video.Brightness.Position:=round(camera.VideoBrightness);
f_video.Gain.Position:=max(min(round(camera.VideoGain),f_video.Gain.Max),f_video.Gain.Min);
f_video.Gamma.Position:=max(min(round(camera.VideoGamma),f_video.Gamma.Max),f_video.Gamma.Min);
f_video.Brightness.Position:=max(min(round(camera.VideoBrightness),f_video.Brightness.Max),f_video.Brightness.Min);
end;

Procedure Tf_main.WheelStatus(Sender: TObject);
Expand Down
1 change: 1 addition & 0 deletions src/u_global.pas
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ TcdcWCSinfo = record // this structure must not be changed
UnitRange:TNumRange = (min:1;max:1;step:1);
NullRange:TNumRange = (min:0;max:0;step:0);
NullCoord:double=-9999;
NullInt: integer=-9999;
Filter0 = 'No change';
Binning0 = '1x1';
dateiso = 'yyyy"-"mm"-"dd"T"hh":"nn":"ss.zzz';
Expand Down

0 comments on commit 191fee0

Please sign in to comment.