private function importStars(InputInterface $input, OutputInterface $output) { $output->writeln("<comment>[{$this->time()}][INFO] Importing stars</comment>"); $size = $this->files['stars']['size']; $filename = $this->files['stars']['name']; // Définition de la progress bar $progress = new ProgressBar($output, $size); $progress->start(); $i = 0; // Ouverture du fichier $handle = fopen("{$this->directory}/{$filename}", 'r'); // Parcours des lignes while ($row = fgetcsv($handle, null, ';')) { $progress->advance(1); // Extraction des variables list($h, $m, $s, $arc_h, $arc_m, $magnitude, $type, $spectrum, $bayer, $flamsteed, $code, $name) = $row; // Corrections $rightAscension = (double) number_format(AstroMaths::hms2hours("{$h} {$m} {$s}"), 6); $declination = (double) number_format(AstroMaths::dms2deg("{$arc_h} {$arc_m}"), 4); $constellation = isset($this->constellations[strtolower($code)]) ? $this->constellations[strtolower($code)] : null; // Normalement, il n'y a pas d'étoile à ces coordonnées ... if ($rightAscension == 0 && $declination == 0) { continue; } // Attention à Sirus qui à une magnitude de -99 pour des raisons de format (3bits) // la vrai magnitude est ainsi -147 // On divise par 100 pour obtenir la magnitude réelle $magnitude = $magnitude == -99 ? -147 / 100 : $magnitude / 100; // Instanciation de l'entité $star = new Star(); $star->setRightAscension($rightAscension); $star->setDeclination($declination); $star->setMagnitute($magnitude); $star->setBayer($bayer); $star->setType($type); $star->setSpectrum($spectrum); $star->setName($name); $star->setConstellation($constellation); // Sauvegarde et persistence $this->stars[] = $star; $this->manager->persist($star); $i++; } // Fin de parcours $progress->finish(); $output->writeln(''); $output->writeln("<info>[{$this->time()}][INFO] Data successfuly loaded !</info>"); $output->writeln("<info>[{$this->time()}][INFO] {$i} lines were loaded</info>"); $output->writeln("<info>[{$this->time()}][INFO] " . ($size - $i) . " lines were ignored</info>"); $output->writeln("<comment>[{$this->time()}][INFO] Flushing data (may take a while)</comment>"); // Enregistrement en BDD $this->manager->flush(); $output->writeln("<info>[{$this->time()}][INFO] Data successfuly flushed into database !</info>"); $output->writeln("<comment>[{$this->time()}][INFO] Done importing stars</comment>"); }
public static function atmospheric_refraction($alt) { $R = 1.02 / self::dtan($alt + 10.3 / ($alt + 5.11)) + 0.0019279; return $alt + AstroMaths::precision($R / self::M_IN_H); }