Commit af6468bd authored by f4eyq's avatar f4eyq

update 15/11

parent 234f45d9
<?php
// extends generic_crxItem
// v04082018
// v112018
class abstractDxClusterSpot{
var $_debug_details = '';
......@@ -118,11 +118,12 @@ class abstractDxClusterSpot{
//New filter date :
if(isset($params['use_date_filter'])) $this->display_spot_after_timestamp_v2 = $params['use_date_filter'];
if(isset($params['display_only_not_contacted_dx'])) $this->display_only_not_contacted_dx = $params['display_only_not_contacted_dx'];
if(isset($params['spots_comment_filter'])) $this->display_spots_comment_filter = $params['spots_comment_filter'];
if(isset($params['spots_comment_filter_in_out'])) $this->display_spots_comment_filter_in_out = $params['spots_comment_filter_in_out'];
if(isset($params['spots_comment_filter_in_out'])) $this->display_spots_comment_filter_in_out = $params['spots_comment_filter_in_out'];
if(isset($params['band_part_filter'])) $this->display_band_part_filter = $params['band_part_filter'];
......
<?php
/*
*************************************************************************************
*
* Crx-cms powered by CRX-PHP-FRAMEWORK http://git.crx.cloud/crx-php/crx-framework
* Copyright (c) Bastien Barbe and contributors. All rights
* reserved.
*
* Crx-cms is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Crx-cms is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*************************************************************************************
*/
/**
* @author Bastien Barbe - CRX-FRAMEWORK
* @date 01/01/2005
* @revision 04082018
* @revision 11112018
* @lib radioamator
* @copyright see header
* @version 1.2.2
*/
//TODO rename to : dxClusterSpot11m
class dxClusterSpots
extends abstractDxClusterSpot{
......@@ -67,11 +45,8 @@ extends abstractDxClusterSpot{
}
*/
$sql_select_time_range='date_spot >= '.$time_select['start'].' AND date_spot <= '.$time_select['end'];
//check is spot data are present for the given time :
$sql="SELECT COUNT(*) AS NB_SPOTCQ_BY_CONT FROM ".$this->_tblSpot." WHERE $sql_select_time_range";
$this->c_db->execSql($sql);
......@@ -198,6 +173,10 @@ extends abstractDxClusterSpot{
function getDataFromParameters($params){
//crxFile::setFileContent('/home/hosting/www_root/ham.crx.cloud/logs/test','params:'.dumper($params));
$this->initGetDataFromParameters($params);
$sql_limit_result = $this->display_filters_start_pointer.",".$this->display_filters_end_pointer;
......@@ -382,13 +361,51 @@ extends abstractDxClusterSpot{
}
if($this->display_spot_after_timestamp_v2){
$datecfg=$this->display_spot_after_timestamp_v2['DATE_FILTER']['value'];
if($sql_set_filter){
$join_this_filter=' AND';
}
else{
$join_this_filter='WHERE';
}
if(isset($datecfg['use_manual_date_setting']) && $datecfg['use_manual_date_setting']==1){
$s=$datecfg['date_start_ts'];
$e=$datecfg['date_end_ts'];
$fs='';
if($s){
$fs='`date_spot` >= '.$s.''; //11m version not time but date_spot column
if($e){
$fs.='AND `date_spot` <= '.$e.'';
}
}
$sql_set_filter.=' ';
$sql_set_filter_columns_settings.=' '.$join_this_filter.' '.$fs;
}
elseif($datecfg['date_last_hours_spots']<>'' && $datecfg['date_last_hours_spots']<>0){
$n=$datecfg['date_last_hours_spots'];//ex 6 hours
if(DEBUG_DEV_SPOT_TIME<>''){
$date=DEBUG_DEV_SPOT_TIME;
}else{
$date=time();
}
$n= $date - ($n * 60 * 60);
$sql_set_filter_columns_settings .= ' '.$join_this_filter.' (`date_spot` >= '.$n.') ';
}
}
$sql_limit_result=" ORDER BY ".$this->display_filters_order_by." DESC LIMIT ".$sql_limit_result;
$final_querie_get_dxcluster_spots = $sql_get_data." ".$sql_set_filter.$sql_set_filter_columns_settings." ".$sql_limit_result;
if($debug)var_dump($final_querie_get_dxcluster_spots);
$this->c_db -> query = $final_querie_get_dxcluster_spots;
//var_dump($final_querie_get_dxcluster_spots);
//var_dump($final_querie_get_dxcluster_spots);
//if($this->debug)crxFile::setFileContent('/home/hosting/www_root/ham.crx.cloud/logs/test','DEBUG:'.dumper($final_querie_get_dxcluster_spots));
$spots = $this->c_db -> getArrayOfResult();
......
......@@ -2,18 +2,36 @@
/*
* CRX M U F calculator
* Info : Based on : MINIMUF, code C ported to PHP by Bastien Barbe
*
* CalcMuf method is based on http://sourcecodebrowser.com/minimuf/3.5/minimuf_8c.html
*
* Add A/K coeff and path information, also HTML interface for calcul ( by F4EYQ )
* Created : 12/05/2014
* Rev : 10/2018
* Version : 0.5
* Version : 0.6
*/
class crxMuf{
var $absorp = array();
var $mufE = array();
var $mufF = array();
var $debug = 0;
var $geo_ind_ak = 0;
var $_useIndiceK_A = 0;
var $_display_footer_legend = 1;
var $_display_header_legend = 1;
////////////////////
//@F4EYQ add on
////////////////////
function appendIndice_K_A(){
/*
The K index is computed once every three hours (eight times a day)
......@@ -35,13 +53,13 @@ K = 9 Extremely severe storm
The A index is linear, and is computed from the eight previous K index values.
It ranges from 0 (quiet) to 400 (severe storm).
A = 0 - 7 Quiet
A = 0 - 7 Quiet
A = 8 - 15 Unsettled
A= 8 - 15 Unsettled
A = 16 - 29 Active
A = 30 - 49 Minor storm
A = 50 - 99 Major storm
A = 100 - 400 Severe storm
A = 50 - 99 Major storm
A = 100 - 400 Severe storm => indice here : 6.0
a k v
1 - 1 -> 0.2
......@@ -100,8 +118,10 @@ A K Ntesla
echo "$a - $k -> $val"._BR_;
}
die();
*/
}
function SGN( $number ) {
......@@ -181,6 +201,7 @@ A K Ntesla
/*
* Loop along path
*/
//fabs not native in php.
for ($k1 = 1 / (2 * $k6); $k1 <= 1 - 1 / (2 * $k6); $k1 += $this->fabs(0.9999 - 1 / $k6)) {
$gtemp = $dist * $k1;
$ftemp = $p * cos($gtemp) + $q * sin($gtemp) * $a;
......@@ -234,99 +255,89 @@ A K Ntesla
}
# ion - determine paratmeters for hop h
#
# This routine determines the reflection zones for each hop along the
# path and computes the minimum F-layer MUF, maximum E-layer MUF,
# ionospheric absorption factor and day/night flags for the entire
# path.
function ion(
$h, # hop index
$d, # path angle (rad)
$fcF, # F-layer critical frequency
$ssn, # current sunspot number
$lat1,
$lon1,
$b1,
$b2,
$lats,
$lons
){
# various refs to arrays
//my $daynight = shift; # ref to daynight array one per hop
//my $mufE = shift;
//my $mufF = shift;
//my $absorp = shift;
# ion - determine paratmeters for hop h
#
# This routine determines the reflection zones for each hop along the
# path and computes the minimum F-layer MUF, maximum E-layer MUF,
# ionospheric absorption factor and day/night flags for the entire
# path.
function ion(
$h, # hop index
$d, # path angle (rad)
$fcF, # F-layer critical frequency
$ssn, # current sunspot number
$lat1,
$lon1,
$b1,
$b2,
$lats,
$lons
){
# various refs to arrays
//my $daynight = shift; # ref to daynight array one per hop
//my $mufE = shift; => php version move to $this->mufE
//my $mufF = shift; => php version move to $this->mufF
//my $absorp = shift; => php version move to $this->absorp
//my $beta; # elevation angle (rad)
//my $psi; # sun zenith angle (rad)
//my $dhop; # hop angle / 2 (rad)
//my $dist; # path angle (rad)
//my $phiF; # F-layer angle of incidence (rad)
//my $phiE; # E-layer angle of incidence (rad)
//my $fcE; # E-layer critical frequency (MHz)
//my $ftemp; # double temp
//my $beta; # elevation angle (rad)
//my $psi; # sun zenith angle (rad)
//my $dhop; # hop angle / 2 (rad)
//my $dist; # path angle (rad)
//my $phiF; # F-layer angle of incidence (rad)
//my $phiE; # E-layer angle of incidence (rad)
//my $fcE; # E-layer critical frequency (MHz)
//my $ftemp; # double temp
# Determine the path geometry, E-layer angle of incidence and
# minimum F-layer MUF. The F-layer MUF is determined from the
# F-layer critical frequency previously calculated by MINIMUF
# 3.5 and the secant law and so depends only on the F-layer
# angle of incidence. This is somewhat of a crock; however,
# doing it with MINIMUF 3.5 on a hop-by-hop basis results in
# rather serious errors.
# Determine the path geometry, E-layer angle of incidence and
# minimum F-layer MUF. The F-layer MUF is determined from the
# F-layer critical frequency previously calculated by MINIMUF
# 3.5 and the secant law and so depends only on the F-layer
# angle of incidence. This is somewhat of a crock; however,
# doing it with MINIMUF 3.5 on a hop-by-hop basis results in
# rather serious errors.
$dhop = $d / ($h * 2);
$beta = atan((cos($dhop) - $this->R / ($this->R + $this->hF)) / sin($dhop));
$ftemp = $this->R * cos($beta) / ($this->R + $this->hE);
$phiE = atan($ftemp / sqrt(1 - $ftemp * $ftemp));
$ftemp = $this->R * cos($beta) / ($this->R + $this->hF);
$phiF = atan($ftemp / sqrt(1 - $ftemp * $ftemp));
$this->absorp[$h] = $this->mufE[$h] = $this->daynight[$h] = 0;
//////////////////////////////////////////////////
////////////////////
//@@@F4EYQ test :
////////////////////
$fcFAKEF=$this->geo_ind_ak_coeff;
if($this->_useIndiceK_A){
$fcFAK=($this->geo_ind_ak*100)/$fcFAKEF;
$fcFAK_COEFF=(($fcF*$fcFAK)/100);
$fcFb=$fcF;
$fcF=$fcF - $fcFAK_COEFF;
$dhop = $d / ($h * 2);
$beta = atan((cos($dhop) - $this->R / ($this->R + $this->hF)) / sin($dhop));
$ftemp = $this->R * cos($beta) / ($this->R + $this->hE);
$phiE = atan($ftemp / sqrt(1 - $ftemp * $ftemp));
$ftemp = $this->R * cos($beta) / ($this->R + $this->hF);
$phiF = atan($ftemp / sqrt(1 - $ftemp * $ftemp));
$this->absorp[$h] = $this->mufE[$h] = $this->daynight[$h] = 0;
////////////////////
//@F4EYQ add on
////////////////////
$fcFAKEF=$this->geo_ind_ak_coeff;
if($this->_useIndiceK_A){
$fcFAK=($this->geo_ind_ak*100)/$fcFAKEF;
$fcFAK_COEFF=(($fcF*$fcFAK)/100);
$fcFb=$fcF;
$fcF=$fcF - $fcFAK_COEFF;
if($this->debug){
echo $this->geo_ind_ak.'/'.round($fcFAK)." / $fcFb => $fcF"._BR_;
}
//echo $this->geo_ind_ak.'/'.round($fcFAK)." / $fcFb => $fcF"._BR_;
//////////////////////////////////////////////////
//$fcF=$this->minAKindex($fcF);
}
//$fcF=$this->minAKindex($fcF);
///////////////////
$this->mufF[$h] = $fcF / cos($phiF);
$this->mufF[$h] = $fcF / cos($phiF);
for ($dist = $dhop; $dist < $d; $dist += $dhop * 2) {
for ($dist = $dhop; $dist < $d; $dist += $dhop * 2) {
# Calculate the E-layer critical frequency and MUF.
$fcE = 0;
$psi = $this->zenith($dist, $lat1, $lon1, $b1, $b2, $lats, $lons);
$ftemp = cos($psi);
if ($ftemp > 0)$fcE = 0.9 * pow((180 + 1.44 * $ssn) * $ftemp, 0.25);
if ($fcE < 0.005 * $ssn)$fcE = 0.005 * $ssn;
$ftemp = $fcE / cos($phiE);
# Calculate the E-layer critical frequency and MUF.
$fcE = 0;
$psi = $this->zenith($dist, $lat1, $lon1, $b1, $b2, $lats, $lons);
$ftemp = cos($psi);
if ($ftemp > 0)$fcE = 0.9 * pow((180 + 1.44 * $ssn) * $ftemp, 0.25);
if ($fcE < 0.005 * $ssn)$fcE = 0.005 * $ssn;
$ftemp = $fcE / cos($phiE);
//////////////////////////////////////////////////
////////////////////
//@@@F4EYQ test :
//@F4EYQ add on
////////////////////
if($this->_useIndiceK_A){
$fcFAK=($this->geo_ind_ak*100)/$fcFAKEF;
$fcFAK_COEFF=(($ftemp*$fcFAK)/100);
......@@ -351,10 +362,9 @@ A K Ntesla
//Night ?
//echo 'N:hour:'.$this->hour." - $ftemp - ($h) ($dist)"._BR_;
$ftemp = 100.8 * $this->d2r;
$this->daynight[$h] |= 2;
$this->daynight[$h] |= 2; // daynight OR binnary with 2
}
......@@ -375,24 +385,21 @@ A K Ntesla
if ($ftemp < 0.1)$ftemp = 0.1;
//////////////////////////////////////////////////
////////////////////
//@@@F4EYQ test :
//@F4EYQ add on
////////////////////
if($this->_useIndiceK_A){
$fcFAK=($this->geo_ind_ak*100)/$fcFAKEF;
$fcFAK_COEFF=(($ftemp*$fcFAK)/100);
$fcFb=$ftemp;
$ftemp=$ftemp+$fcFAK_COEFF;
}
//$ftemp=$this->minAKindex($ftemp);
//////////////////////////////////////////////////
////////////////////
$this->absorp[$h] += $ftemp;
}
}
function minAKindex($val){
......@@ -472,7 +479,7 @@ A K Ntesla
$this->NTEMP = 290; # receiver noise temperature (K)
$this->DELTAF = 2500; # communication bandwidth (Hz)
$this->MPATH = 3; # multipath threshold (dB)
$this->GLOSS = 3; # ground-reflection loss (dB)
$this->GLOSS = 3; # ground-reflection loss (dB) / -3db by hop
$this->SLOSS = 10; # excess system loss
$this->noise = 10 * log10($this->BOLTZ * $this->NTEMP * $this->DELTAF) + 30;
......@@ -532,6 +539,7 @@ A K Ntesla
}
function mainProcess(){
$this->freq = array(1.8,3.5,7.0,10.1,14.0,18.1,21.0,24.9,28.0,50.0); # working frequencies (MHz)
$nfreq = count($this->freq); # number of frequencies
......@@ -611,7 +619,6 @@ A K Ntesla
//Distance: <b>".round($d * $this->R)."
if($this->_display_header_legend){
$rs_out = "RxSens: <b>$rsens</b> dBM &nbsp;&nbsp;SFI:<b>$flux</b>
&nbsp;&nbsp;R(ssn):<b>".round($ssn)."</b>
......@@ -632,19 +639,13 @@ A K Ntesla
$head .= "<b>ZE</b>: Sun zenith angle at the midpoint of the path."._BR_._BR_;
}
$head .='<table>';
$head .='<tr bgcolor="#999999">
$head .='<table class="mufResultCalc">';
$head .='<tr class="mufResultCalcHeader">
<td>UT</td>
<td>LT</td>
<td>MUF</td>
<td>ZE</td>
<!-- <td>PATH</td> -->
<td>INF</td>
';
for ($i = 0; $i < $nfreq; $i++){
......@@ -701,13 +702,12 @@ A K Ntesla
$this->hour=$hour;
$this->ion($h, $d, $fcF, $ssn, $lat1, $lon1, $b1, $theta, $lats, $lons);
}
$test=90 - $psi * $this->r2d;
$test=round($test);
$muf=round($this->mufF[$hop],1);
$zen=$test;
$zen=$test; //Sun zenith angle at the midpoint of the path
$mdh=sprintf("%02d",$dh);
$mtime=sprintf("%02d",$time);
$out='
......@@ -721,15 +721,25 @@ A K Ntesla
$hout='';
$test_1='';
for ($i = 0; $i < $nfreq; $i++) {
//echo $hop.' | '.$this->freq[$i].' | '. $dB1. ' | '. $antgain._BR_;
$n = $this->pathloss($hop, $this->freq[$i], $dB1, $rsens, $antgain);
$hout.= $this->ds($n,$rsens);
//$test_1=$this->daynight[$n]+$test_1;
//$test_1='min hop:'.$hop;
}
//$p=$this->pathInfoF4EYQ($test_1);
//$path='<td>'.$p.'</td>';
////////////////////
//@F4EYQ add on
////////////////////
$p=$this->pathInfoCalc($test_1);
$path='<td>'.$p.'</td>';
$rs_out.='<tr bgcolor="#999999">'.$out.$path.$hout.'</tr>';
$rs_out.='<tr>'.$out.$path.$hout.'</tr>';
////////////////////
}
......@@ -745,15 +755,15 @@ A K Ntesla
}
var $_display_footer_legend = 1;
var $_display_header_legend = 1;
//TODO
function pathInfoF4EYQ($p){
////////////////////
//@F4EYQ add on
////////////////////
function pathInfoCalc($p){
//if($p == 0){ return $p; }
return $p;
if ($p & 4){
$p=$p.':4';
//$p='M';
......@@ -778,13 +788,34 @@ A K Ntesla
if($h==0)return '<td>&nbsp;</td>';
if ($this->daynight[$h] & 4) {
$c2 = 's';
} elseif ($this->daynight[$h] & 16) {
$c2 = 'm';
} else {
$c2 = ' ';
}
$c2 = ' ';
if ($this->daynight[$h] & 4) { //binary op
$c2 = 's';// 's' that the signal is likely to be noisy
//h 8 , daynight : 23
} elseif ($this->daynight[$h] & 16) {
//h 8, daynight : 19
$c2 = 'm';// 'm' it means that there is likely to be much fading
}
# official minimuf version of display
# ----------------------------------------
elseif ($this->daynight[$h] & 3 == 3) {
$c2 .= 'x';
}
if ($this->daynight[$h] & 1) {
$c2 .= 'j';
}
if ($this->daynight[$h] & 2) {
$c2 .= 'n';
}
# ----------------------------------------
$l = $this->dB2[$h] - $rsens;
$s = (int) ($l / 6);
......@@ -797,7 +828,7 @@ A K Ntesla
if($s>5 && $s<=7){ $col='#B3FFB3'; }
if($s>7){ $col='#80FF80'; }
$val="$c2"."S$s$plus";
return '<td bgcolor="'.$col.'">'.$val.'</td>';
return '<td bgcolor="'.$col.'" class="mufResultCalcTextReportCell">'.$val.'</td>';
}
function pathloss(
......@@ -823,9 +854,12 @@ A K Ntesla
# is less than the noise or when the frequency exceeds the F-
# layer MUF are considered unusable.
$level = $this->noise;
$j = 0;
$coef=0.85;
//$coef=0.99;
//$coef=0.99;//test
for ($h = $hop; $h < $hop + 3; $h++) {
// 0 . 8 5 => 14.831480879948 -> 12.606758747956
......@@ -848,6 +882,7 @@ A K Ntesla
$this->dB2[$h] = $signal; // - 3 db by hop
# Paths where the signal is greater than the
# noise, but less than the receiver sensitivity
# are marked 's'. Paths below the E-layer MUF
......@@ -870,6 +905,8 @@ A K Ntesla
}
# We have found the best path. If this path is less than 3 dB
# above the RMS sum of the other paths, the path is marked 'm'.
......
<?php
//Interface class to use dxClusterSpot HAM or 11M.
//u:12072018
//u:112018
class dxClusterSpot {
var $__mode = '';
var $c_db = '';
var $debug = false;
function setDebug($d){
$this->debug=$d;
}
function getDxClusterStatsContinentDxSpotRepartition($db='spot',$time_select=array('start','end'),$user_continent='EU',$nb_total_spots=0,$user_band_selected='ALL',$debug=0){
......@@ -155,12 +163,14 @@ class dxClusterSpot {
if($this->__mode == 'HAM'){
$s=new dxClusterSpotHam();
$s->setDbHandler($this->c_db);
$s->setDebug($this->debug);