kunjara / jyotish

PHP library for calculations in Vedic astrology
http://jyotish.su
175 stars 118 forks source link

Notice: Undefined offset #25

Open nitinmukesh opened 3 years ago

nitinmukesh commented 3 years ago

I was able to setup the code and run index.php using XAMPP using PHP 5.6 version.

index.php

<?php

require './vendor/autoload.php';

use Jyotish\Base\Data;
use Jyotish\Base\Locality;
use Jyotish\Base\Analysis;
use Jyotish\Ganita\Method\Swetest;
use Jyotish\Dasha\Dasha;
$Locality = new Locality([
            'longitude' => "11.09",
            'latitude' => "79.6",
            'altitude' => 0,
            ]);
$DateTime = new DateTime();
$DateTime->setTimezone(new DateTimeZone('Asia/Kolkata'));
$DateTime->setDate(2017,09,26);
$DateTime->setTime(19,18);
$Ganita = new Swetest(["swetest" => "./vendor/kunjara/swetest/win/"]);
// for linux
// run sudo apt install libswe-dev
// after that use 
// $Ganita = new Swetest(["swetest" => "/usr/bin/"]);
$data = new Data($DateTime, $Locality, $Ganita);
// To Calculate Panchangam
$data->calcParams();
$data->calcRising();
$data->calcPanchanga();
// To calculate Upagraha
$data->calcUpagraha();
// To calculate Birth chart Divisions
$data->calcVargaData(["D1","D2","D3","D4","D7","D9","D10","D12",
"D16","D20","D24","D27","D30","D40","D45","D60"]);

I am however getting the following errors and no idea what is wrong. I also checked "vendor\kunjara\swetest\win" for swetest.exe and it is present. Please any help on solving the issue


Notice: Undefined offset: 2 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 281

Notice: Undefined offset: 2 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 283

Notice: Undefined offset: 3 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 283

Notice: Undefined offset: 5 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 284

Notice: Undefined offset: 6 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 284

Notice: Undefined offset: 3 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 281

Notice: Undefined offset: 2 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 283

Notice: Undefined offset: 3 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 283

Notice: Undefined offset: 5 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 284

Notice: Undefined offset: 6 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 284

Notice: Undefined offset: 4 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 281

Notice: Undefined offset: 2 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 283

Notice: Undefined offset: 3 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 283

Notice: Undefined offset: 5 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 284

Notice: Undefined offset: 6 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 284

Notice: Undefined offset: 5 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 281

Notice: Undefined offset: 2 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 283

Notice: Undefined offset: 3 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 283

Notice: Undefined offset: 5 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 284

Notice: Undefined offset: 6 in D:\xampp\htdocs\jyotish\src\Ganita\Method\Swetest.php on line 284

Warning: Division by zero in D:\xampp\htdocs\jyotish\src\Panchanga\AngaDefiner.php on line 267
qwertynik commented 2 years ago

Did you manage to resolve this @nitinmukesh?

nitinmukesh commented 2 years ago

@qwertynik Nope

qwertynik commented 2 years ago

@nitinmukesh Notices and warnings can be ignored. Ideally they should be addressed.

nitinmukesh commented 2 years ago

@qwertynik Did you managed to run it

qwertynik commented 2 years ago

Yes @nitinmukesh Adding below line at the end of the code sample you posted should help. print_r($data->getData());

nitinmukesh commented 2 years ago

@qwertynik Thank you. I actually deleted this as I don't know PHP and could not solve the issue.

I am gonna try again. Thinking of converting this to nodejs and create public API for everyone to use. Not sure how much time I will get to learn PHP.

krishnaguragain commented 2 years ago

@nitinmukesh I managed to run this. Let me know what kind of help do you need at krishnaguragain @ outlook.com

qwertynik commented 2 years ago

@krishnaguragain

Did you manage to calculate the Nakshatras using this library?

nitinmukesh commented 2 years ago

@qwertynik Nikhil I am also looking to calculate Nakshatras for each planet. I see there is a lot of code related to the same but not exposed in output.

I see this site is using the same code and shows Nakshatras. https://sidereal.live/

nitinmukesh commented 2 years ago

@krishnaguragain I managed to run it and see the output. Thank you.

jantech commented 2 years ago

@qwertynik Nikhil I am also looking to calculate Nakshatras for each planet. I see there is a lot of code related to the same but not exposed in output.

I see this site is using the same code and shows Nakshatras. https://sidereal.live/

@nitinmukesh , Could you please share the details how to resolve the issues? Thanks.

jscuba commented 2 years ago

This is a relatively simple way to get this library up and running on AWS Lambda. https://github.com/jscuba/jyotish-lambda

I'll post this to a few of the issues. It might be helpful as a reference too.

I had to sort of manually pull the nakshatras. I'm not much of a PHP programmer as you can probably tell.

nitinmukesh commented 2 years ago

Thank you @jscuba . https://github.com/jscuba/jyotish-lambda/blob/main/index.php

Any possibility to add Combust and Retro against each planet.

It's there in GrahaEnvironment.php
public function isAstangata()

nitinmukesh commented 2 years ago

@jantech

Install XAMPP with PHP 7 Download the code from here and put in xampp/htdocs folder https://github.com/jscuba/jyotish

install dependencies using composer

jscuba commented 2 years ago

@nitinmukesh You can check the speed of the planet to see if it's retrograde. Negative value indicates retrograde. I added combustion. I also saw getRashiAvastha() there, so I added the dignity as well.

nitinmukesh commented 2 years ago

@jscuba

I see the isAstangata is not working correctly. Sun at 12 and Moon at 19 degree is showing as non combust which is incorrect. I found the issue is in public function isAstangata() { if (in_array($this->optionBhagaAstangata, [Biblio::BOOK_SS, Biblio::BOOK_BJ])) {

It is always picking default value as 6 whereas it should pick values from Graha.php public static $bhagaAstangata = [

I am not sure how to fix it. Please could you help with this issue

nitinmukesh commented 2 years ago

@jscuba

I added additional information in the code provided by you. Please update in your code

` $nakshatra = null; foreach ($vargaData['graha'] as $grahaKey => $value) { $nakshatra = $angaDefiner->getNakshatra(false, false, $grahaKey); $vargaData['graha'][$grahaKey]['nakshatra'] = $nakshatra; $Graha = Graha::getInstance($grahaKey)->setEnvironment($data); $vargaData['graha'][$grahaKey]['astangata'] = $Graha->isAstangata(); // combustion $vargaData['graha'][$grahaKey]['rashiAvastha'] = $Graha->getRashiAvastha(); // dignity $vargaData['graha'][$grahaKey]['gocharastha'] = $Graha->isGocharastha(); // gocharastha $vargaData['graha'][$grahaKey]['bhavaCharacter'] = $Graha->getBhavaCharacter(); // Bhava Character $vargaData['graha'][$grahaKey]['tempRelation'] = $Graha->getTempRelation(); // Get tatkalika (temporary) relations $vargaData['graha'][$grahaKey]['relation'] = $Graha->getRelation(); // Get summary relations $vargaData['graha'][$grahaKey]['vargottama'] = $Graha->isVargottama(); // Vargottama $vargaData['graha'][$grahaKey]['yogakaraka'] = $Graha->isYogakaraka(); // yogakaraka $vargaData['graha'][$grahaKey]['mrityu'] = $Graha->isMrityu(); // graha is in mrityu bhaga $vargaData['graha'][$grahaKey]['pushkaraNavamsha'] = $Graha->isPushkara(Graha::PUSHKARA_NAVAMSHA); // graha is in pushkara navamsha $vargaData['graha'][$grahaKey]['pushkaraBhaga'] = $Graha->isPushkara(Graha::PUSHKARA_BHAGA); // graha is in pushkara bhaga $vargaData['graha'][$grahaKey]['yuddha'] = $Graha->isYuddha(); // graha is in planetary war $vargaData['graha'][$grahaKey]['avastha'] = $Graha->getAvastha(); // Get avastha of graha $vargaData['graha'][$grahaKey]['dispositor'] = $Graha->getDispositor(); // Get ruler of the bhava, where graha is positioned

}

`

jscuba commented 2 years ago

@nitinmukesh I ended up writing my own combustion calculation. This is some javascript to give you an idea.

  const sunDegree = vargaData.graha.Sy.rashi * 30.0 + vargaData.graha.Sy.degree

  // and then for each planet...

  let dist = Math.abs(sunDegree - (data.rashi * 30.0 + data.degree))
  dist = Math.min(dist, 360 - dist)

  switch (data.graha) {
    case 'Sy':
      break
    case 'Ch':
      if (dist < 12) {
        data.combust = true
      }
      break
    case 'Ma':
      if (dist < 17) {
        data.combust = true
      }
      break
    case 'Bu':
      if (data.speed >= 0) {
        if (dist < 14) {
          data.combust = true
        }
      } else if (dist < 12) {
        data.combust = true
      }
      break
    case 'Gu':
      if (dist < 11) {
        data.combust = true
      }
      break
    case 'Sk':
      if (data.speed >= 0) {
        if (dist < 10) {
          data.combust = true
        }
      } else if (dist < 8) {
        data.combust = true
      }
      break
    case 'Sa':
      if (dist < 15) {
        data.combust = true
      }
      break
    case 'Ra':
      break
    case 'Ke':
      break
    default:
      break
  }

Thanks for the additional info for jyotish-lambda. I'll add it.

nitinmukesh commented 2 years ago

@jscuba Thank you m8.

Have a look at this.

You can mouse over graha in D1 https://golden-longma-0a62a5.netlify.app/nits.html

Only desktop friendly

nitinmukesh commented 2 years ago

@jscuba

Do you have any understanding how to prepare Bhava Chalit. I have seen several videos and read articles but can't gather my thoughts on how to implement (coding). May be I am old enough to get this through my head.

jscuba commented 2 years ago

@nitinmukesh No, sorry. I hadn't heard of it until you mentioned it.