From 5daa5f301d48a286d4d3bb820d00d75da6ab6d65 Mon Sep 17 00:00:00 2001
From: Joe Taylor <joe@princeton.edu>
Date: Fri, 2 Dec 2022 11:35:52 -0500
Subject: [PATCH] Let MAP65 compute self Doppler using *.iq filename values for
 date and time.

---
 map65/libm65/astrosub.f90 | 12 ++++++++++++
 map65/mainwindow.cpp      | 20 +++++++++++++++++++-
 map65/mainwindow.h        |  3 +++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/map65/libm65/astrosub.f90 b/map65/libm65/astrosub.f90
index 64dddb00c..ce25a0d94 100644
--- a/map65/libm65/astrosub.f90
+++ b/map65/libm65/astrosub.f90
@@ -12,3 +12,15 @@ subroutine astrosub(nyear,month,nday,uth8,nfreq,mygrid,hisgrid,          &
 
   return  
 end subroutine astrosub
+
+subroutine astrosub00(nyear,month,nday,uth8,nfreq,mygrid,ndop00)
+
+  implicit real*8 (a-h,o-z)
+  character*6 mygrid
+
+  call astrosub(nyear,month,nday,uth8,nfreq,mygrid,mygrid,               &
+     AzSun8,ElSun8,AzMoon8,ElMoon8,AzMoonB8,ElMoonB8,ntsky,ndop,ndop00,  &
+     RAMoon8,DecMoon8,Dgrd8,poloffset8,xnr8)
+
+  return
+end subroutine astrosub00
diff --git a/map65/mainwindow.cpp b/map65/mainwindow.cpp
index adddfeac2..98a34a164 100644
--- a/map65/mainwindow.cpp
+++ b/map65/mainwindow.cpp
@@ -1293,7 +1293,25 @@ void MainWindow::decode()                                       //decode()
   datcom_.mousefqso=m_wide_graph_window->QSOfreq();
   datcom_.ndepth=m_ndepth;
   datcom_.ndiskdat=0;
-  if(m_diskData) datcom_.ndiskdat=1;
+  if(m_diskData) {
+    datcom_.ndiskdat=1;
+    int i0=m_path.indexOf(".tf2");
+    if(i0<0) i0=m_path.indexOf(".iq");
+    if(i0>0) {
+      // Compute self Doppler using the filename for Date and Time
+      int nyear=m_path.mid(i0-11,2).toInt()+2000;
+      int month=m_path.mid(i0-9,2).toInt();
+      int nday=m_path.mid(i0-7,2).toInt();
+      int nhr=m_path.mid(i0-4,2).toInt();
+      int nmin=m_path.mid(i0-2,2).toInt();
+      double uth=nhr + nmin/60.0;
+      int nfreq=(int)datcom_.fcenter;
+      int ndop00;
+
+      astrosub00_(&nyear, &month, &nday, &uth, &nfreq, m_myGrid.toLatin1(),&ndop00,6);
+      datcom_.nfast=ndop00;               //Send self Doppler to decoder, via datcom
+    }
+  }
   datcom_.neme=0;
   if(ui->actionOnly_EME_calls->isChecked()) datcom_.neme=1;
 
diff --git a/map65/mainwindow.h b/map65/mainwindow.h
index ebee97403..efe58b866 100644
--- a/map65/mainwindow.h
+++ b/map65/mainwindow.h
@@ -322,6 +322,9 @@ extern "C" {
               int len1, int len2);
 
   int ptt_(int* nport, int* itx, int* iptt);
+
+  void astrosub00_ (int* nyear, int* month, int* nday, double* uth, int* nfreq,
+                    const char* mygrid, int* ndop00, int len1);
   }
 
 #endif // MAINWINDOW_H