I have number of days from 1 to 180 days, decreasing and increasing dates from the date $epoch='2020-05-11'. The full period = 365.25 days, an amplitude, a frequency and a phase will be added later in the end to create a sine wave. This is not the whole code attached, but I need that each day to be converted to radians or associated? How to solve this, I have searched via internet just conversion from degrees to radians.
The data input are coming from bat file, just further to easily make changes:
C:\Strawberry\perl\bin\perl.exe D:\perl\ex4444.pl Peri_GPS ZAT1_GPS 2020-05-11 180
pause
and the code itself:
#!/usr/bin/perl
use Math::Random::OO::Normal;
use Time::Local;
use Time::Localtime;
use POSIX qw(strftime);
my $filename = 'D:\perl\program.txt';
open (FH, '>', $filename)
or die $!;
my ($station1, $station2, $epoch, $count_day) = @ARGV;
$day_a2 = -1;
$day_a1 = $day_a2 - $count_day;
$day_a3 = 1;
$day_a4 = $day_a3 + $count_day;
my ($year, $month, $day) = split('-', $epoch);
$epoch = timelocal(0, 0, 0, $day, $month-1, $year-1900);
$day_sec = 60*60*24;
$interval=$count_day*$day_sec;
$epoch1=$epoch-86400;
$epoch2=$epoch1-$interval;
$epoch3=$epoch+86400;
$epoch4=$epoch3+$interval;
@x1=(); @x2=();
for ($d = $day_a1; $d <= $day_a2; $d++){
$epoch2 += $day_sec;
push (@x1, $d);
printf FH scalar(strftime " %Y %m %d %H %M", localtime($epoch2));
printf FH " %14.4f \n";
close $FH;
}
for ($d = $day_a3; $d <= $day_a4; $d++){
$epoch3 += $day_sec;
push (@x2, $d);
print FH scalar(strftime " %Y %m %d %H %M", localtime($epoch3));
printf FH " %14.4f \n";
close $FH;
}
You have a range and you want to find a fraction of that range. This is simple multiplication.
For my time zone, that outputs
Notice how
$fraction
simply varies from -1 to +1? Well, so does sin(x)!Say we add the following to the program:
The builtin
sin
takes radians as input, so one would expect dates that following the following distribution:The program now outputs the following: