PyDTMC output graph overlaps on code in a notebook - python-3.x

I just installed PyDTMC and use it in a Jupyter notebook.
Following the examples on this page https://pypi.org/project/PyDTMC/ leads to a surprising result: plot_graph() overlaps on code above.
How could I fix that?
(m.plot_graph(mc, dpi=200) shows the full graph, but I don't like this workaround)
Note: jupyter-notebook 6.3.0, Python 3.8.5, PyDTMC 4.9.0 (on Archlinux)

The problem was mentioned here https://github.com/TommasoBelluzzo/PyDTMC/issues/6 with a fixing suggestion. Fix applied in this fork https://github.com/yagu0/PyDTMC.
It's still unclear why the figure size needs to be augmented (setting a higher dpi also works, but doesn't look like a clean solution). So I let this post open, in case of someone could explain :-)

Related

cutoff error using custom kernel in Smooth.ppp

I need to use a custom kernel with the Smooth function, but attempting this throws an error even though I specify cutoff:
Error: The argument ‘cutoff’ is required when a non-Gaussian kernel is specified and scalekernel=FALSE
n=4; PPP=ppp(rep(1:n,n),rep(1:n,each=n), c(1,n),c(1,n), marks=1:n^2);
Smooth.ppp(PPP,cutoff=50,kernel=gaussian,at="points")
Here is a toy example that makes the same error. I'm not 100% sure whether this is an error or something that's unintuitive to me. Thank you!!
This is a bug. Thank you for bringing it to our attention.
It has been fixed in the development version of spatstat.core (2.4-2.003) which is available at the GitHub repository
The bug only affects the case where kernel is a function, at="points", and scalekernel=FALSE. In the meantime you can get the desired result by either
Adding scalekernel=TRUE and sigma=1, or
Deleting at="points" so that the result is a pixel image Z say, and extracting the desired values by Z[PPP].

How can i preserve the source raster projection when using gdal_translate?

I'm currently working on a small raster refining tool. The goal is, to have a simple CLI tool, to compute tiles from a georeferenced source raster and create a corresponding index.shp. For this I'm using python 3.7 and gdal. The tool runs smoothly and generates the expected tiles and shapefile, but it gets rid of the projection, which is stored in the source raster. Qgis defaults the newly computed tiles to EPSG 4326 while informing me about an unknown projection. The original raster is in EPSG 25832.
My Setup:
Windows 10 64 bit
Python 3.7.2
Gdal I cannot access the specific version, since gdal-config is not installed and I cannot make it work, but it is 64-bit and I installed it through the binaries provided on gisinternals.com. Windows software list says GDAL 204 MSVC 2017.
While running the script, I get error messages telling me about missing files, e.g. pcs.csv, datum.csv ellipsoid.csv and so on. This indicates that having those files, would fix my problem.
But oddly enough, I have used Osgeo4W to install, python 2.7 with gdal and it works like a charm, of course having adjusted the python parts. Tiles get calculated and stay in the projection of the source. Without any external files which specify a projection, in fact using the exact same data which is really confusing to me.
To my understanding, there is no flag or option which forces gdal to keep the projection. If have overlooked or missunderstood the docs im glad for advice.
Before anyone asks, i know that using the osgeo4w installer is obviously the easy and working solution here. But keeping in mind that python 2.7 will soon be discontinued and also using this as a chance to learn new things i wanted to build a 3.7 based tool with gdal installed on my machine
The corresponding code looks like this and does the following :
1.) Command string is build
2.) string is handed to os.system, which in turn executes accordingly
for i in range(0, width, tilelenght):
y = 0
for j in range(0, height, tilelenght):
gdaltranString = f'gdal_translate -of GTIFF -srcwin {i}, {j}, {tilelenght}, {tilelenght} {input_filepath} {output_filepath}{x}_{y}.tif'
subprocess.run(gdaltranString)
y = y+1
x = x+1
The expected result, would be a collection of functional .tif files which have the EPSG code of the source file, in this case 25832.
But as already mentioned, the projection gets lost somewhere in the process.
So,i have found the solution to my problem, without really understanding how it became an issue to begin with.
The solution was to create an user variable GDAL_DATA with the path to the projection definition files.
The weird thing is, i now have GDAL_DATA, as system variable and user variable, both pointing to the same directory.
If someone knows more about the mysterious ways of windows system variables, please share your wisdom, or the source of said wisdom.

Rattle(useGtkBuilder = TRUE) starts Rattle, but Rattle itself is frozen

I have version 3.4.0 of R. on Windows 7. I installed the library rattle. There were errors, but I found out from Stackoverflow that using rattle( useGtkBuilder = TRUE) solves the problem.
It did - only partially. Now, when I load the CSV file, and click on the execute button, in the Rattle GUI, nothing happens !
All the menu options are apparently working, but no file is getting loaded.
Any idea ?
I could solve this problem, in the following way..
>install.packages("rattle", repos="http://rattle.togaware.com", type="source")
>install.packages("https://cran.r-project.org/bin/windows/contrib/3.3/RGtk2_2.20.31.zip", repos=NULL)
>library(RGtk2)
>library(rattle)
>rattle()
There were several messages asking me to install packages related to Cairo and XML, which i allowed to proceed.
Dont know why it exactly worked..but everything is working fine, and i ran a logistic regression model, and the results and the log-code, look just super.
Thanks and hope it helps other users, towards a simple/lucid way out,
Regards,
Raghavendra B
As per the Rattle trouble shooting page, the current version of Rattle on CRAN has an issue with the most recent release of RGtk2 on CRAN. A fix is being readied for CRAN at present but in the meantime the following should fix it for RGtk2 2.20.33:
> install.packages("https://togaware.com/access/rattle_5.0.14.tar.gz",
repos = NULL,
type = "source")

Output generated is different with output in NLTK tutorial

Today I start to learn Python because I need to use NLTK in my assignment. In order to learn it, I follow the tutorial in this site http://www.nltk.org/book/ch01.html. However, when I run the programme in Python interpreter, the output produced is not same with what has been shown in the website and I have no idea on what thing that this output wants to tell me.
(Below is the picture of the output:)
Input: >>> from nltk.book import *
Output (After I hit 'Enter'):
So now my questions are what is the error about and if there is a way to solve it, then what should I need to do?
Thanks for looking into my problem.
This appears to be a known bug with nltk and Python 3. It seems to have been fixed within the past two weeks, but I expect you'll have to wait until there's a release that contains the fix. You could try installing from source.

Any tips on creating a Pygame Developer Console?

I've been getting my feet wet with Python and Pygame, and after a few bugs in a very basic game that I have been making, I've thought to myself that having some sort of console that can deal with string input (from a developer) would be very handy.
Here's an example:
I notice the player disappears after double jumping. So, in the console that I will hopefully create, I would type in:
>> report_bug("Player disappears after double jumping")
Where report_bug(string) is a user-defined function that will do the following things:
report_bug(string):
# Check if debug file already exists; create new file if none exists
# Append string to file, along with other extra info
Could someone point me in the right direction? Will I have to create something from scratch, and if so, how would I go about doing that? I've attempted to modify the source code from: http://www.pygame.org/project-pygame-console-287-.html, however it is 9 years-old and made for Python 2.x, when I'm using Python 3.4. Any help would be greatly appreciated.
I've managed to get the 2.X PygameConsole version 0.7 working, so I will stick with that!
Edit: I will attempt to port PyConsole to Python 3.X and hopefully add some more features so newcomers can easily understand what is going on.

Resources